summaryrefslogtreecommitdiffstats
path: root/layouts/partials/scripts-front.html
diff options
context:
space:
mode:
authoramzrk22020-06-01 15:44:04 +0800
committeramzrk22020-06-01 15:44:04 +0800
commit02c3891865c7741b8f772aea75cc01564d2f0ff4 (patch)
treedb0e4dd8c3ef95181f5e665ca09f731b75de0387 /layouts/partials/scripts-front.html
parent2338da969d3bc1b2bc26df9f7192dd20a0906c5b (diff)
downloadhugo-theme-fuji-02c3891865c7741b8f772aea75cc01564d2f0ff4.tar.gz
hugo-theme-fuji-02c3891865c7741b8f772aea75cc01564d2f0ff4.tar.bz2
hugo-theme-fuji-02c3891865c7741b8f772aea75cc01564d2f0ff4.zip
Remove jQuery
Diffstat (limited to 'layouts/partials/scripts-front.html')
-rw-r--r--layouts/partials/scripts-front.html19
1 files changed, 8 insertions, 11 deletions
diff --git a/layouts/partials/scripts-front.html b/layouts/partials/scripts-front.html
index 9425769..c516aad 100644
--- a/layouts/partials/scripts-front.html
+++ b/layouts/partials/scripts-front.html
@@ -1,16 +1,13 @@
<script data-cfasync="false">
// detect theme data in localStorage
- // if diff 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';
- }
- });
+ var fujiThemeData = localStorage.getItem('fuji_data-theme');
+ // if first look, set theme mode to auto
+ if (!fujiThemeData) {
+ localStorage.setItem('fuji_data-theme', 'auto');
+ } else {
+ // if not auto mode, change the data-theme attribute of body
+ if (fujiThemeData !== 'auto') {
+ document.body.setAttribute('data-theme', fujiThemeData === 'dark' ? 'dark' : 'light');
}
}
</script>