aboutsummaryrefslogtreecommitdiff
path: root/templates/index.html
blob: 6f697ae63c2c7198a2ec4f8ab9dc31bc4cbeb778 (plain) (blame)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{% import "_macros.html" as macros %}
{% import "_nav.html" as nav %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>{% block title %}{{ config.title }}{% endblock title %}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    {% block favicon %}
        <link rel="icon" type="image/png" href="/favicon.ico">
    {% endblock favicon %}
    {% include "_variables.html" %}
    <link rel="stylesheet" href="/normalize.css">
    <link rel="stylesheet" href="{{ get_url(path="juice.css") }}">
    {% block head %}
    {% endblock head %}
</head>

<body>
    {% block header %}
    <header class="box-shadow top-nav">
      {{ macros::render_header() }}
    </header>
    {% endblock header %}

    <main>
        {% block mainnav %}
            <div class="toc {% if page.ancestors or section.ancestors %}{% else %}toc-homepage{% endif %}">
                <div class="toc-sticky">
                    {% if page %}
                        {{ nav::page(target=page) }}
                    {% else %}
                        {{ nav::section(target=section) }}
                    {% endif %}
                </div>
            </div>
        {% endblock mainnav %}

        <div class="content text">
            {% block content %}
        <div id="features" class="heading-text">{{ section.title }} </div>
            {{ section.content | safe }}
            {% endblock content %}
        </div>

        {% block sidebar %}
        {% endblock sidebar %}
    </main>

    {% block footer %}
    <footer>
        <small class="subtext">
        Édité et hébergé par <a href="https://deuxfleurs.fr">Deuxfleurs</a>,
        généré par <a href="https://www.getzola.org">Zola</a>,
        thème dérivé de <a href="https://github.com/huhu/juice">Juice</a>,
        servi par <a href="https://garagehq.deuxfleurs.fr/">Garage</a>.
        </small>
        <small class="subtext">Last updated on: {{ now() | date(format="%d %B %Y") }}</small>
    </footer>
    {% endblock footer %}
</body>
<script>
    function highlightNav(heading) {
        let pathname = location.pathname;
        document.querySelectorAll(".toc a").forEach((item) => {
            item.classList.remove("active");
        });
        document.querySelector(".toc a[href$='" + pathname + "#" + heading + "']").classList.add("active");
    }

    let currentHeading = "";
    window.onscroll = function () {
        let h = document.querySelectorAll("h1,h2,h3,h4,h5,h6");
        let elementArr = [];

        h.forEach(item => {
            if (item.id !== "") {
                elementArr[item.id] = item.getBoundingClientRect().top;
            }
        });
        elementArr.sort();
        for (let key in elementArr) {
            if (!elementArr.hasOwnProperty(key)) {
                continue;
            }
            if (elementArr[key] > 0 && elementArr[key] < 300) {
                if (currentHeading !== key) {
                    highlightNav(key);
                    currentHeading = key;
                }
                break;
            }
        }
    }
</script>

</html>