summaryrefslogtreecommitdiff
path: root/layouts/_partials
diff options
context:
space:
mode:
authorEltrac <eltrac@vmi3030963.contaboserver.net>2026-02-10 16:03:25 +0800
committerEltrac <eltrac@vmi3030963.contaboserver.net>2026-02-10 16:03:25 +0800
commit229e3ac00a9361aa59f6add3a87fb9e1ff539f6c (patch)
treec537037db370156c149be7d007539c7d6575a5ca /layouts/_partials
parent783e1f1f8acd635f67e002d047450fa98dc56290 (diff)
parent9a0f7b785ed13f0506b2c7ab8c7da6b0ca398450 (diff)
Merge branch 'master' of https://src.eltr.ac/eltrac/geedeapro
Diffstat (limited to 'layouts/_partials')
-rw-r--r--layouts/_partials/head.html3
-rw-r--r--layouts/_partials/head/scripts.html4
-rw-r--r--layouts/_partials/header/other-navigation.html10
-rw-r--r--layouts/_partials/scripts.html9
-rw-r--r--layouts/_partials/scripts/libra-js.html6
-rw-r--r--layouts/_partials/scripts/toc-js.html41
6 files changed, 24 insertions, 49 deletions
diff --git a/layouts/_partials/head.html b/layouts/_partials/head.html
index a50dd333..3a8cd25c 100644
--- a/layouts/_partials/head.html
+++ b/layouts/_partials/head.html
@@ -4,6 +4,7 @@
<link rel="preconnect" href="https://r2.eltr.ac" />
{{ hugo.Generator }}
{{ partial "head/siteinfo" . }}
- {{ partial "head/css" . }}
{{ partial "head/verification" . }}
+ {{ partial "head/css" . }}
+ {{ partial "head/scripts" . }}
</head>
diff --git a/layouts/_partials/head/scripts.html b/layouts/_partials/head/scripts.html
new file mode 100644
index 00000000..f067944c
--- /dev/null
+++ b/layouts/_partials/head/scripts.html
@@ -0,0 +1,4 @@
+{{ with resources.Get "js/darkmode.js" }}
+<script>{{ .Content | safeJS }}</script>
+{{ end }}
+
diff --git a/layouts/_partials/header/other-navigation.html b/layouts/_partials/header/other-navigation.html
index 662f1076..db37477d 100644
--- a/layouts/_partials/header/other-navigation.html
+++ b/layouts/_partials/header/other-navigation.html
@@ -1,6 +1,14 @@
{{ $langButtonSize := "w-4 h-4" }}
<div class="flex gap-2 pr-2">
+ <!-- theme switch -->
+ <select id="theme-select"
+ class="bg-neutral/10 border-1 border-[var(--text-color)] border-solid rd text-[var(--text-color)] font-serif text-size-[0.5rem] font-extrabold">
+ {{ $switches := slice "auto" "light" "dark" }}
+ {{ range $switches }}
+ <option value="{{ . }}">{{ T (printf "theme.%s" .) }}</option>
+ {{ end }}
+ </select>
<!-- language switch -->
{{- $lang := .Site.Language.Lang -}}
{{- $switch := dict
@@ -9,7 +17,7 @@
{{- $entry := index $switch $lang -}}
<a
href="{{ $entry.url }}"
- class="rounded-full text-center hover:no-underline {{ $langButtonSize }}
+ class="rd-full text-center hover:no-underline {{ $langButtonSize }}
bg-neutral/10 border-1 border-[var(--text-color)] border-solid
bg-[var(--block-background-color)]
flex items-center justify-center"
diff --git a/layouts/_partials/scripts.html b/layouts/_partials/scripts.html
index 6ad03632..f7e9c36b 100644
--- a/layouts/_partials/scripts.html
+++ b/layouts/_partials/scripts.html
@@ -1,3 +1,12 @@
+<!-- Theme Switch -->
+<script>
+document.addEventListener("DOMContentLoaded", () => {
+ const themeSelect = document.getElementById('theme-select')
+ themeSelect.value = localStorage.getItem('geedeapro.theme')
+ themeSelect.onchange = () => switchTheme(themeSelect.value, true)
+})
+</script>
+
<!-- global JS -->
{{ $commonJS := slice
(resources.Get "js/tooltip.js")
diff --git a/layouts/_partials/scripts/libra-js.html b/layouts/_partials/scripts/libra-js.html
deleted file mode 100644
index 95e121ed..00000000
--- a/layouts/_partials/scripts/libra-js.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<script type="module">
-document.addEventListener('DOMContentLoaded', async () => {
- const { default: LightBox } = await import('/js/libra.min.js');
- const lightbox = new LightBox({ offset: { x: -8, y: -80 } });
-});
-</script>
diff --git a/layouts/_partials/scripts/toc-js.html b/layouts/_partials/scripts/toc-js.html
deleted file mode 100644
index 110f2357..00000000
--- a/layouts/_partials/scripts/toc-js.html
+++ /dev/null
@@ -1,41 +0,0 @@
-{{ if .Params.toc }}
-<script>
-document.addEventListener('DOMContentLoaded', () => {
- const toc = document.getElementById('toc');
- if (!toc) return;
-
- const headings = document.querySelectorAll('h2, h3');
- const observer = new IntersectionObserver(entries => {
- entries.forEach(entry => {
- if (!entry.isIntersecting) return;
-
- const id = entry.target.id;
- const tocLink = toc.querySelector(`a[href="#${id}"]`);
- if (!tocLink) return;
-
- const listItem = tocLink.parentElement;
- const isH2 = entry.target.tagName === 'H2';
-
- // Clear all active states when a new H2 is encountered
- if (isH2) {
- toc.querySelectorAll('li.active').forEach(el => el.classList.remove('active'));
- }
-
- // Set current item as active
- listItem.classList.add('active');
-
- // If this is an H3, find and activate its parent H2
- if (!isH2) {
- const parentH2Item = listItem.closest('ul').previousElementSibling?.closest('li');
- if (parentH2Item) parentH2Item.classList.add('active');
- }
- });
- }, {
- rootMargin: '0px 0px -50% 0px',
- threshold: 0.5
- });
-
- headings.forEach(heading => observer.observe(heading));
-});
-</script>
-{{ end }}