diff --git a/assets/js/main.js b/assets/js/main.js index 7e0efb8..5c10af4 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -44,6 +44,11 @@ function initLazyVideos(root) { initLazyVideos(); +// ── Close lightbox on navigation ────────────────────────────────── +document.body.addEventListener("htmx:beforeSwap", () => { + window.dispatchEvent(new CustomEvent("lightbox:close")); +}); + // ── After HTMX partial swap ──────────────────────────────────────── document.body.addEventListener("htmx:afterSwap", (e) => { initLazyVideos(e.target); @@ -53,10 +58,10 @@ document.body.addEventListener("htmx:afterSwap", (e) => { // ── After HTMX history restore (back / forward navigation) ──────── document.body.addEventListener("htmx:historyRestore", () => { - // Sync nav active state to the restored URL + window.dispatchEvent(new CustomEvent("lightbox:close")); + if (window.Alpine) Alpine.store("nav").path = window.location.pathname; - // Complete the progress bar (htmx:afterSettle never fires on history restore) const bar = document.getElementById("progress-bar"); if (bar) { bar.style.width = "100%"; @@ -69,11 +74,11 @@ document.body.addEventListener("htmx:historyRestore", () => { const main = document.getElementById("main-content"); if (!main) return; if (window.Alpine) Alpine.initTree(main); - // Reload and replay autoplay videos (autoplay attr is ignored on restore) main.querySelectorAll("video[autoplay]").forEach((v) => { v.load(); v.play().catch(() => {}); }); window.scrollTo({ top: 0, behavior: "instant" }); + window.dispatchEvent(new Event("scroll")); }); diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index f9c7742..3ca3683 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -19,12 +19,101 @@ {{- block "page-background" . -}}{{- end -}} -
+
{{- block "main" . }}{{- end }}
{{- partial "footer.html" . -}} + + + diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 8712e92..4c523e3 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -112,22 +112,7 @@ {{- $lbItems = $lbItems | append $entry -}} {{- end -}} -
+
Gallery @@ -135,12 +120,12 @@
-
{{- range $i, $img := $bundleImages -}} {{- $stem := $img.Name | strings.TrimSuffix ".png" -}} {{- $video := $.Resources.GetMatch (printf "%s.mp4" $stem) -}} -
+
{{- if $video -}} @@ -152,106 +137,6 @@ {{- end -}}
- - -
{{- else -}}