guide.deuxfleurs.fr/templates/index.html

118 lines
3.5 KiB
HTML

{% 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">
<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>