aboutsummaryrefslogtreecommitdiff
path: root/templates/index.html
blob: 54fb4739265196691eda2f9e8ba9643288337366 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{% import "_macros.html" as macros %}
<!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">
      {{ macros::render_header() }}
    </header>
    {% endblock header %}

    <main>
        {% block toc %}
	{% if page.ancestors %}
	{% set section = get_section(path=page.ancestors | last) %}
	{% endif %}
	{% if section.ancestors %}
	{% set parent = get_section(path=section.ancestors | last) %}
	{% endif %}
        <div class="toc">
            <div class="toc-sticky">
                <div class="toc-item toc-section">
                    <a class="subtext" href="{{section.permalink | safe}}">{{ section.title }}</a>
                </div>
		{% if section.subsections %}
                {% for s in section.subsections %}
		{% set p = get_section(path=s) %}
                <div class="toc-item">
                    <a class="subtext" href="{{ p.permalink | safe}}">{{ p.title }}</a>
                </div>
                {% endfor %}
		{% endif %}

		{% if section.pages %}
                {% for p in section.pages %}
                <div class="toc-item">
                    <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a>
                </div>
                {% endfor %}
		{% endif %}
		{% if parent %}
                  <div class="toc-item">
                    <a class="subtext" href="{{parent.permalink | safe}}">← Retour</a>
                  </div>
		{% endif %}
            </div>
        </div>
        {% endblock toc %}

        <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>
    </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>