Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zzossig/hugo-theme-zzo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzzossig <zzossig@gmail.com>2020-10-26 05:17:37 +0300
committerzzossig <zzossig@gmail.com>2020-10-26 05:17:37 +0300
commitbdcf6190fbc3b8691ab1fa319917ad3d131430db (patch)
tree0afe0e742719af9e47846ddcc03d97dcaaa393ef
parented920bdd6d7bd0e5e45e7a2f9f32db3452c0a06c (diff)
theme name change bug fixed
#334
-rw-r--r--layouts/partials/head/scripts.html27
1 files changed, 26 insertions, 1 deletions
diff --git a/layouts/partials/head/scripts.html b/layouts/partials/head/scripts.html
index abd1484..19e2ec0 100644
--- a/layouts/partials/head/scripts.html
+++ b/layouts/partials/head/scripts.html
@@ -451,6 +451,17 @@
var rootEleme = document.getElementById('root');
var selectThemeElem = document.querySelectorAll('.select-theme');
var selectThemeItemElem = document.querySelectorAll('.select-theme__item');
+
+ {{ $skinDarkCode := (i18n "skin-dark") }}
+ var skinDarkCode = JSON.parse({{ $skinDarkCode | jsonify }});
+ {{ $skinLightCode := (i18n "skin-light") }}
+ var skinLightCode = JSON.parse({{ $skinLightCode | jsonify }});
+ {{ $skinHackerCode := (i18n "skin-hacker") }}
+ var skinHackerCode = JSON.parse({{ $skinHackerCode | jsonify }});
+ {{ $skinSolarizedCode := (i18n "skin-solarized") }}
+ var skinSolarizedCode = JSON.parse({{ $skinSolarizedCode | jsonify }});
+ {{ $skinKimbieCode := (i18n "skin-kimbie") }}
+ var skinKimbieCode = JSON.parse({{ $skinKimbieCode | jsonify }});
var setMetaColor = function(themeColor) {
var metaMsapplicationTileColor = document.getElementsByName('msapplication-TileColor')[0];
@@ -485,6 +496,20 @@
metaAppleMobileWebAappStatusBarStyle.setAttribute('content', '#eee8d5');
}
}
+
+ var parseSkinCode = function(themeText) {
+ if (themeText === skinDarkCode) {
+ return 'dark';
+ } else if (themeText === skinLightCode) {
+ return 'light';
+ } else if (themeText === skinHackerCode) {
+ return 'hacker';
+ } else if (themeText === skinSolarizedCode) {
+ return 'solarized';
+ } else if (themeText === skinKimbieCode) {
+ return 'kimbie';
+ }
+ }
if (localTheme) {
selectThemeItemElem ?
@@ -504,7 +529,7 @@
selectThemeItemElem ?
selectThemeItemElem.forEach(function (v, i) {
v.addEventListener('click', function (e) {
- var selectedThemeVariant = e.target.text.trim();
+ var selectedThemeVariant = parseSkinCode(e.target.text.trim());
localStorage.setItem('theme', selectedThemeVariant);
setMetaColor(selectedThemeVariant);