summaryrefslogtreecommitdiff
path: root/static/js/theme.js
diff options
context:
space:
mode:
authorgarhve <git@garhve.com>2023-01-02 06:02:01 +0800
committergarhve <git@garhve.com>2023-01-02 06:02:01 +0800
commitbe772f40c42711de54a3331db2781b1511acba9d (patch)
tree0808a7750d3c1055b0e86071c219d872775b1f92 /static/js/theme.js
parent3ae5ecf803ed2d4ece2c9da6d91aae0f075c5b0c (diff)
change to zola
Diffstat (limited to 'static/js/theme.js')
-rw-r--r--static/js/theme.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/static/js/theme.js b/static/js/theme.js
new file mode 100644
index 0000000..be2a9d1
--- /dev/null
+++ b/static/js/theme.js
@@ -0,0 +1,22 @@
+const key = 'current_emily_zola_style';
+
+function getTheme() {
+ let theme = document.getElementById('stylesheet');
+ let current_style = localStorage.getItem(key);
+ if (current_style === null) {
+ localStorage.setItem(key, theme.href);
+ }
+ theme.href = localStorage.getItem(key);
+}
+
+function changeTheme() {
+ let current_style = localStorage.getItem(key);
+ if (current_style.includes('dark')) {
+ localStorage.setItem(key, '/light.css');
+ }
+ else {
+ localStorage.setItem(key, '/dark.css');
+ }
+ let theme = document.getElementById('stylesheet');
+ theme.href = localStorage.getItem(key);
+} \ No newline at end of file