diff options
Diffstat (limited to 'layouts/_default/baseof.html')
-rw-r--r-- | layouts/_default/baseof.html | 14 |
1 files changed, 11 insertions, 3 deletions
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"> |