From a67109db24766b3e9d5e5ea6b5c30bbd89d8a34a Mon Sep 17 00:00:00 2001 From: zaaarf Date: Fri, 22 Dec 2023 01:07:32 +0100 Subject: [PATCH] fix: embed js into page so tera can preprocess --- static/js/script.js | 21 --------------------- templates/head.html | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 22 deletions(-) delete mode 100644 static/js/script.js diff --git a/static/js/script.js b/static/js/script.js deleted file mode 100644 index 205d215..0000000 --- a/static/js/script.js +++ /dev/null @@ -1,21 +0,0 @@ -const setTheme = (theme) => { - document.documentElement.className = theme; - localStorage.setItem('theme', theme); -} - -const hasCodeRun = localStorage.getItem('hasCodeRun'); - -if (!hasCodeRun) { - const defaultTheme = "{{ config.extra.default_theme }}"; - setTheme(defaultTheme); - localStorage.setItem('hasCodeRun', 'true'); -} - -const getTheme = () => { - const theme = localStorage.getItem('theme'); - if (theme) { - setTheme(theme); - } -} - -getTheme(); \ No newline at end of file diff --git a/templates/head.html b/templates/head.html index 0bf38fd..8001bcb 100644 --- a/templates/head.html +++ b/templates/head.html @@ -92,5 +92,27 @@ {% block css %} {% endblock css %} - +