diff options
author | amzrk2 | 2020-05-27 22:53:13 +0800 |
---|---|---|
committer | amzrk2 | 2020-05-27 22:53:13 +0800 |
commit | dfb6e1f80754c1c8f2d4d332c5292319f008a67b (patch) | |
tree | fd8c0cf13e03613b6a39c662b6a0ced87fb69157 /layouts/partials/scripts-front.html | |
parent | aa5290aeef9df1c583fdf30290351968df9215dc (diff) | |
download | hugo-theme-fuji-dfb6e1f80754c1c8f2d4d332c5292319f008a67b.tar.gz hugo-theme-fuji-dfb6e1f80754c1c8f2d4d332c5292319f008a67b.tar.bz2 hugo-theme-fuji-dfb6e1f80754c1c8f2d4d332c5292319f008a67b.zip |
v2 original port
Diffstat (limited to 'layouts/partials/scripts-front.html')
-rw-r--r-- | layouts/partials/scripts-front.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/layouts/partials/scripts-front.html b/layouts/partials/scripts-front.html new file mode 100644 index 0000000..9fa99b6 --- /dev/null +++ b/layouts/partials/scripts-front.html @@ -0,0 +1,18 @@ +<script data-cfasync="false"> + // detect theme data in localStorage + // change the data-theme attribute of body + var fujiThemeData = localStorage.getItem('fuji_theme'); + if (fujiThemeData) { + if ($('body').attr('data-theme') !== fujiThemeData) { + $('body').attr('data-theme', (index, attr) => { + if (fujiThemeData === 'dark') { + return 'dark'; + } else { + return 'light'; + } + }); + } + } else { + localStorage.setItem('fuji_theme', $('body').attr('data-theme')); + } +</script>
\ No newline at end of file |