summaryrefslogtreecommitdiff
path: root/layouts/_partials/scripts.html
blob: 2c63748d826ee9d12711a6c308be5e4f4d117596 (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
<!-- Theme Switch -->
<script>
document.addEventListener("DOMContentLoaded", () => {
    const themeSelect = document.getElementById('theme-select')
    if (themeSelect) {
        themeSelect.value = localStorage.getItem('geedeapro.theme')
        themeSelect.onchange = () => switchTheme(themeSelect.value, true)
    }
})
</script>

<!-- Note for Interaction Area: auto-close it if seen -->
<script>
if (localStorage.getItem('geedeapro.closeInteractionNote')) {
    document.getElementById('interaction-note').classList.add('hidden')
}
</script>

<!-- global JS -->
{{ $commonJS := slice
  (resources.Get "js/tooltip.js")
  (resources.Get "js/instantpage.min.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/back2top.js")
    (resources.Get "js/iine.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: -48 },
    selector: "[data-libra]:not(.disable-libra *)",
  });
});
</script>

<!-- GoatCounter -->
<script data-goatcounter="https://stats.geedea.pro/count"
        async src="//stats.geedea.pro/count.js"></script>