summaryrefslogtreecommitdiffstats
path: root/layouts/partials/scripts-front.html
diff options
context:
space:
mode:
authoramzrk22020-05-27 22:53:13 +0800
committeramzrk22020-05-27 22:53:13 +0800
commitdfb6e1f80754c1c8f2d4d332c5292319f008a67b (patch)
treefd8c0cf13e03613b6a39c662b6a0ced87fb69157 /layouts/partials/scripts-front.html
parentaa5290aeef9df1c583fdf30290351968df9215dc (diff)
downloadhugo-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.html18
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