summaryrefslogtreecommitdiff
path: root/layout/_partial/scripts.ejs
diff options
context:
space:
mode:
Diffstat (limited to 'layout/_partial/scripts.ejs')
-rw-r--r--layout/_partial/scripts.ejs27
1 files changed, 14 insertions, 13 deletions
diff --git a/layout/_partial/scripts.ejs b/layout/_partial/scripts.ejs
index a60011f..c07d83d 100644
--- a/layout/_partial/scripts.ejs
+++ b/layout/_partial/scripts.ejs
@@ -11,7 +11,6 @@
<% } %>
<!-- Darkmode support -->
-<link rel="stylesheet" type="text/css" href="https://unpkg.com/bulma-prefers-dark" />
<%- js('js/darkmode.js') %>
<script>
var darklistener = new DarkmodeListener();
@@ -25,18 +24,20 @@
<link id="highlight-dark-theme" rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/styles/<%= theme.highlight.darkmode %>.min.css">
<script>
- const theme_selector = (mode) => {
- if (mode === SystemDarkmodePrefrence.dark) {
- document.getElementById("highlight-light-theme").setAttribute("disabled", "disabled");
- document.getElementById("highlight-dark-theme").removeAttribute("disabled");
- } else {
- document.getElementById("highlight-dark-theme").setAttribute("disabled", "disabled");
- document.getElementById("highlight-light-theme").removeAttribute("disabled");
- }
- };
- theme_selector(darklistener.mode());
- darklistener.add(theme_selector);
- hljs.initHighlightingOnLoad();
+ window.addEventListener("load", () => {
+ const theme_selector = (mode) => {
+ if (mode === SystemDarkmodePrefrence.dark) {
+ document.getElementById("highlight-light-theme").setAttribute("disabled", "disabled");
+ document.getElementById("highlight-dark-theme").removeAttribute("disabled");
+ } else {
+ document.getElementById("highlight-dark-theme").setAttribute("disabled", "disabled");
+ document.getElementById("highlight-light-theme").removeAttribute("disabled");
+ }
+ };
+ theme_selector(darklistener.mode());
+ darklistener.add(theme_selector);
+ hljs.initHighlightingOnLoad();
+ }, false);
</script>
<% } %>