summaryrefslogtreecommitdiff
path: root/layout/_partial/scripts.ejs
blob: ab83cf5ed6f72f1536f260c3171e747dbd7025ac (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
<!-- Lazyload support -->
<%- js('js/script.js') %>
<% if (theme.lazyload) { %>
    <script defer src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.min.js"></script>
    <script>
        window.lazyLoadOptions = {
            elements_selector: ".lazy",
            threshold: 0,
            effect: "fadeIn"
        };
    </script>
<% } %>

<!-- Highlight.js support -->
<% if (theme.highlight.enable === true) { %> 
    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/highlight.pack.min.js"></script>
    <link id="highlight-light-theme" rel="stylesheet" 
        href="https://cdn.jsdelivr.net/npm/[email protected]/styles/<%= theme.highlight.lightmode %>.min.css">
    <link id="highlight-dark-theme" rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/[email protected]/styles/<%= theme.highlight.darkmode %>.min.css">
    <script>
        window.addEventListener("load", () => {
            const theme_selector = (mode) => {
                if (mode === SystemDarkmodePrefrence.dark) {
                    document.getElementById("highlight-light-theme").setAttribute("disabled", "disabled");
                    document.getElementById("highlight-dark-theme").removeAttribute("disabled");
                } else {
                    document.getElementById("highlight-dark-theme").setAttribute("disabled", "disabled");
                    document.getElementById("highlight-light-theme").removeAttribute("disabled");
                }
            };
            darklistener.add(theme_selector);
            hljs.initHighlightingOnLoad();
        }, false);
    </script>
<% } %>

<!-- Shikwasa Player support -->
<% if (is_post() && theme.podcast && page.podcast) { %>
    <script defer src="https://cdn.jsdelivr.net/npm/shikwasa/dist/shikwasa.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/shikwasa/dist/shikwasa.min.css">
<% } %>