summaryrefslogtreecommitdiff
path: root/layouts/partials/scripts.html
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2024-12-19 14:41:26 +0800
committerEltrac <hi@guhub.cn>2024-12-19 14:41:26 +0800
commit103be55e7daec04b8da85ee175a9ec2317a167b0 (patch)
tree99af7983332c60d0f276416a34d936a5581fede8 /layouts/partials/scripts.html
parentc695b9511ba695bc57144b8c3f72e08625cce29a (diff)
refactor: disable theme and move layout files to root
Diffstat (limited to 'layouts/partials/scripts.html')
-rw-r--r--layouts/partials/scripts.html31
1 files changed, 31 insertions, 0 deletions
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
new file mode 100644
index 00000000..a2cbb997
--- /dev/null
+++ b/layouts/partials/scripts.html
@@ -0,0 +1,31 @@
+<!-- third-party libraries -->
+<script src="https://unpkg.com/swup@4"></script>
+<script src="https://unpkg.com/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.umd.js"></script>
+<script type="module">
+import { init } from 'https://unpkg.com/@waline/client@v3/dist/waline.js';
+
+/* === waline === */
+
+function loadWalineComment() {
+ // terminate if no waline container is found
+ const container = document.getElementById("waline");
+ if (!container) return;
+
+ // initialize waline
+ const path_suffix = window.location.pathname.endsWith('/') ? '' : '/';
+ waline_options.path = window.location.pathname + path_suffix;
+ try {
+ init(waline_options);
+ } catch (error) { console.log(error) }
+
+ // track waline button events
+ const walineButton = document.querySelector("#waline > div > div.wl-comment > div > div.wl-footer > div.wl-info > button.primary.wl-btn");
+ walineButton.addEventListener("click", () => umami.track("Comment"));
+}
+
+loadWalineComment();
+
+/* === swup === */
+const swup = new Swup();
+swup.hooks.on('page:view', loadWalineComment);
+</script>