blob: 746134be150955f6ab78e51a2b4975394465f37a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<!-- third-party libraries -->
{{ range .Site.Params.externalJSFiles -}}
<script src="{{ $.Site.Params.staticPrefix }}{{ . | relURL }}"></script>
{{- end }}
<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();
/* === lazyload === */
var lazyLoadInstance = new LazyLoad();
lazyLoadInstance.update();
/* === Fancybox === */
Fancybox.bind("[data-fancybox]");
/* === tocbot === */
function loadToc() {
tocbot.init({
tocSelector: '#toc',
contentSelector: '#post-content',
headingSelector: 'h2, h3:not(blockquote > h3)',
hasInnerContainers: true,
scrollSmoothOffset: -30
});
}
loadToc();
/* === swup === */
const swup = new Swup();
swup.hooks.on('page:view', () => {
loadWalineComment();
lazyLoadInstance.update();
Fancybox.bind("[data-fancybox]");
loadToc();
});
</script>
|