diff options
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 |