feat: add side toc support and update toc style

This commit is contained in:
st1020 2025-10-02 20:07:02 +08:00
parent 9d208b7bd1
commit b7a197c648
10 changed files with 291 additions and 241 deletions

View file

@ -0,0 +1,23 @@
{% if page.toc and page.extra.side_toc | default(value=config.extra.side_toc) %}
<nav
class="prose prose-neutral dark:prose-invert prose-a:block prose-a:truncate prose-a:font-normal prose-a:secondary-link max-h-lvh overflow-y-auto px-2 pt-18 pb-4"
>
<b class="ml-1.5">Table of Contents</b>
<ul>
{% for h1 in page.toc %}
<li>
<a href="#{{ h1.id | safe }}">{{ h1.title }}</a>
{% if h1.children %}
<ul>
{% for h2 in h1.children %}
<li>
<a href="#{{ h2.id | safe }}">{{ h2.title }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
</nav>
{% endif %}