guide.deuxfleurs.fr/templates/index.html

119 lines
3.5 KiB
HTML
Raw Normal View History

2022-05-10 15:52:28 +00:00
{% 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 %}
2022-05-11 15:53:45 +00:00
{% if page.ancestors %}
{% set section = get_section(path=page.ancestors | last) %}
{% endif %}
{% if section.ancestors %}
{% set parent = get_section(path=section.ancestors | last) %}
{% endif %}
2022-05-10 15:52:28 +00:00
<div class="toc">
<div class="toc-sticky">
2022-05-11 15:53:45 +00:00
<div class="toc-item toc-section">
<a class="subtext" href="{{section.permalink | safe}}">{{ section.title }}</a>
2022-05-10 15:52:28 +00:00
</div>
2022-05-11 15:53:45 +00:00
{% 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>
2022-05-10 15:52:28 +00:00
</div>
{% endfor %}
2022-05-11 15:53:45 +00:00
{% endif %}
{% if section.pages %}
{% for p in section.pages %}
<div class="toc-item">
<a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a>
</div>
2022-05-10 15:52:28 +00:00
{% endfor %}
2022-05-11 15:53:45 +00:00
{% endif %}
{% if parent %}
<div class="toc-item">
<a class="subtext" href="{{parent.permalink | safe}}">← Retour</a>
</div>
{% endif %}
2022-05-10 15:52:28 +00:00
</div>
</div>
{% endblock toc %}
<div class="content text">
{% block content %}
2022-05-11 15:53:45 +00:00
<div id="features" class="heading-text">{{ section.title }} </div>
2022-05-10 15:52:28 +00:00
{{ section.content | safe }}
{% endblock content %}
</div>
{% block sidebar %}
{% endblock sidebar %}
</main>
{% block footer %}
<footer>
<small class="subtext">
<a href="https://huhu.io">Huhu.io</a> © 2021
</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>