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

github.com/matsuyoshi30/harbor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasaya Watanabe <sfbgwm30@gmail.com>2020-11-21 13:27:38 +0300
committerGitHub <noreply@github.com>2020-11-21 13:27:38 +0300
commit6d506997f7594c09f3051537dda119a2ecfe223f (patch)
treeb0bb5ba887df25fdc7f85091985ac03c6d5fdfb9 /layouts
parent7fe2f636dbb36d24b5a5bacd7c69dceb7dce02d7 (diff)
parent7993444234b5100e85d30e3944bb906bc79587cd (diff)
Merge pull request #72 from lomion0815/themeLoading
fix #64
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/head.html12
1 files changed, 11 insertions, 1 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 746961a..6991dfa 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -11,11 +11,21 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="alternate" type="application/rss+xml" href="{{ .Site.BaseURL }}index.xml" title="{{ .Site.Title }}">
<!-- Stylesheets -->
-<link id="dark-mode-theme" rel="stylesheet" href="{{ .Site.BaseURL }}css/dark.css" />
<link rel="stylesheet" href="{{ .Site.BaseURL }}fontawesome/css/all.min.css" />
{{ range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ . | absURL }}" />
{{ end }}
+<link id="dark-mode-theme" rel="stylesheet" href="{{ .Site.BaseURL }}css/dark.css" />
+<!-- Load theme mode from browser cache -->
+<script>
+var darkTheme = document.getElementById("dark-mode-theme");
+var storedTheme = localStorage.getItem("dark-mode-storage");
+if (storedTheme === "dark") {
+ darkTheme.disabled = false;
+} else if (storedTheme === "light") {
+ darkTheme.disabled = true;
+}
+</script>
<!-- script -->
<script src="{{ .Site.BaseURL }}js/bundle.js"></script>
<script src="{{ .Site.BaseURL }}js/instantpage.min.js" type="module" defer></script>