Browse Source

sass deprecation warning fix

#34
zzossig 5 years ago
parent
commit
71d26cb70d
2 changed files with 12 additions and 3 deletions
  1. 1 0
      assets/sass/abstracts/_mixins.scss
  2. 11 3
      layouts/_default/baseof.html

+ 1 - 0
assets/sass/abstracts/_mixins.scss

@@ -1,3 +1,4 @@
+$theme-map: null;
 @mixin themify($themes) {
   @each $theme, $map in $themes {
     .theme__#{$theme} & {

+ 11 - 3
layouts/_default/baseof.html

@@ -12,12 +12,20 @@
     {{ partial "head/services" . }}
 </head>
 
-<body id="root" class="theme__{{ index .Site.Params.themeOptions 0 }}">
+{{ $themeOptions := .Site.Params.themeOptions }}
+<body id="root" class="theme__{{ index $themeOptions 0 }}">
     <script>
+        var rootElem = document.getElementById('root');
+        var themeOptions = JSON.parse({{ $themeOptions | jsonify }});
         var localTheme = localStorage.getItem('theme');
+
         if (localTheme) {
-            document.getElementById('root').className = `theme__${localTheme}`;
-        }        
+            if (themeOptions && themeOptions.length > 0) {
+                themeOptions.includes(localTheme) ? 
+                rootElem.className = `theme__${localTheme}` :
+                rootElem.className = `theme__${themeOptions[0]}`;
+            }
+        }
     </script>
     
     <div id="container">