- Pass extracted anchors through template context - Render anchor links under active page when page.toc is true - Hierarchical indentation by heading level (h2-h6) - CSS styling: smaller font, muted color, border-left indicator - Add toc: true to templates.md as example
73 lines
2.8 KiB
HTML
73 lines
2.8 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
{% if page.description %}
|
|
<meta name="description" content="{{ page.description }}" />{% endif %}
|
|
<title>{{ title }} | {{ config.title }}</title>
|
|
<link rel="canonical" href="{{ base_url }}{{ page_path }}" />
|
|
<link rel="stylesheet" href="{{ prefix }}/style.css" />
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css" crossorigin="anonymous"
|
|
media="print" onload="this.media='all'" />
|
|
<noscript>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css"
|
|
crossorigin="anonymous" />
|
|
</noscript>
|
|
<link rel="icon" type="image/png" href="{{ prefix }}/logo.png" />
|
|
</head>
|
|
|
|
<body>
|
|
<aside class="sidebar">
|
|
<header>
|
|
<a href="{{ prefix }}/index.html" class="logo">
|
|
<img src="{{ prefix }}/logo.png" alt="" class="logo-img" />
|
|
sukr
|
|
</a>
|
|
<span class="tagline">suckless static sites</span>
|
|
<input type="checkbox" id="nav-toggle" class="nav-toggle" />
|
|
<label for="nav-toggle" class="hamburger" aria-label="Toggle navigation">
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
</label>
|
|
</header>
|
|
<nav>
|
|
{% for item in nav %}
|
|
{% set section_prefix = item.path | replace(from="index.html", to="") %}
|
|
{% set is_current_section = page_path is starting_with(section_prefix) %}
|
|
<a href="{{ prefix }}{{ item.path }}" {% if page_path==item.path %}class="active" {% endif %}>{{ item.label }}</a>
|
|
{% if page_path == item.path and page.toc and anchors %}
|
|
<div class="nav-anchors">
|
|
{% for anchor in anchors %}
|
|
<a href="#{{ anchor.id }}" class="anchor-link level-{{ anchor.level }}">{{ anchor.label }}</a>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% if config.nested_nav and item.children %}
|
|
<div class="nav-children{% if is_current_section %} expanded{% endif %}">
|
|
{% for child in item.children %}
|
|
<a href="{{ prefix }}{{ child.path }}" {% if page_path==child.path %}class="active" {% endif %}>{{ child.label
|
|
}}</a>
|
|
{% if page_path == child.path and page.toc and anchors %}
|
|
<div class="nav-anchors">
|
|
{% for anchor in anchors %}
|
|
<a href="#{{ anchor.id }}" class="anchor-link level-{{ anchor.level }}">{{ anchor.label }}</a>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</nav>
|
|
<footer class="sidebar-footer">
|
|
<a href="https://github.com/nrdxp/sukr">GitHub</a>
|
|
<span>© 2024 nrdxp — MIT</span>
|
|
</footer>
|
|
</aside>
|
|
<main>{% block content %}{% endblock content %}</main>
|
|
</body>
|
|
|
|
</html> |