diff options
author | Masaya Watanabe <sfbgwm30@gmail.com> | 2020-11-21 13:27:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-21 13:27:38 +0300 |
commit | 6d506997f7594c09f3051537dda119a2ecfe223f (patch) | |
tree | b0bb5ba887df25fdc7f85091985ac03c6d5fdfb9 /layouts | |
parent | 7fe2f636dbb36d24b5a5bacd7c69dceb7dce02d7 (diff) | |
parent | 7993444234b5100e85d30e3944bb906bc79587cd (diff) |
Merge pull request #72 from lomion0815/themeLoading
fix #64
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/head.html | 12 |
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> |