diff options
author | zzossig <zzossig@gmail.com> | 2020-10-29 21:39:37 +0300 |
---|---|---|
committer | zzossig <zzossig@gmail.com> | 2020-10-29 21:39:37 +0300 |
commit | 71d26cb70da8470d19010224e2b8b465ca92b1fc (patch) | |
tree | b10879f4a0157d2ac22d2f4d4b29f6e553d40ef4 | |
parent | 933f73dfd82604bc8cf92bb83b25e07e2a59f092 (diff) |
sass deprecation warning fix
#34
-rw-r--r-- | assets/sass/abstracts/_mixins.scss | 1 | ||||
-rw-r--r-- | layouts/_default/baseof.html | 14 |
2 files changed, 12 insertions, 3 deletions
diff --git a/assets/sass/abstracts/_mixins.scss b/assets/sass/abstracts/_mixins.scss index 4fe0749..090a0cd 100644 --- a/assets/sass/abstracts/_mixins.scss +++ b/assets/sass/abstracts/_mixins.scss @@ -1,3 +1,4 @@ +$theme-map: null; @mixin themify($themes) { @each $theme, $map in $themes { .theme__#{$theme} & { diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 90acffd..b184e8a 100644 --- a/layouts/_default/baseof.html +++ b/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"> |