diff options
Diffstat (limited to 'layouts/partials/scripts.html')
| -rw-r--r-- | layouts/partials/scripts.html | 31 |
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> |
