blob: 668116402cbaffeb4e08de5a10533c3e2cc71608 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
<!-- global JS -->
{{ $commonJS := slice
(resources.Get "js/tooltip.js")
(resources.Get "js/instantpage.js")
}}
{{ $commonBundle := $commonJS | resources.Concat "js/common-bundle.js" | minify | fingerprint }}
<script src="{{ $commonBundle.RelPermalink }}" integrity="{{ $commonBundle.Data.Integrity }}" defer></script>
<!-- content page only JS -->
{{ if not .IsHome }}
{{ $articleJS := slice
(resources.Get "js/toc.js")
(resources.Get "js/inject-footnotes.js")
(resources.Get "js/back2top.js")
(resources.Get "js/giscus-count.js")
(resources.Get "js/like.js")
}}
{{ $articleBundle := $articleJS | resources.Concat "js/article-bundle.js" | minify | fingerprint }}
<script src="{{ $articleBundle.RelPermalink }}" integrity="{{ $articleBundle.Data.Integrity }}" defer></script>
{{ end }}
<!-- libra.js -->
<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>
<!-- GoatCounter -->
<script data-goatcounter="https://eltrac.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>
{{ if and (not .IsHome) .Params.hasAplayer }}
<script>
document.addEventListener("DOMContentLoaded", function () {
const lazyPlayers = document.querySelectorAll(".lazy-aplayer");
if (!lazyPlayers.length) return;
const loadAPlayer = () => {
if (window.APlayer) return Promise.resolve();
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = "https://unpkg.com/aplayer@1.10.1/dist/APlayer.min.js";
script.onload = resolve;
script.onerror = reject;
document.body.appendChild(script);
});
};
const observer = new IntersectionObserver((entries, obs) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
loadAPlayer().then(() => {
const el = entry.target;
const id = el.dataset.id ? `-` + el.dataset.id : ``;
const container = document.createElement('div');
container.id = `aplayer${id}`;
el.appendChild(container);
const ap = new APlayer({
container: container,
audio: [{
name: el.dataset.name,
artist: el.dataset.artist,
url: el.dataset.url,
cover: el.dataset.cover
}]
});
obs.unobserve(el);
});
}
});
});
lazyPlayers.forEach(player => observer.observe(player));
});
</script>
{{ end }}
|