feat: add table of contents to blog posts

This commit is contained in:
Oliver Davies 2022-07-20 12:00:00 +01:00
parent 05748fd193
commit dbaca137f7
3 changed files with 14 additions and 0 deletions

View file

@ -0,0 +1,3 @@
<a name="{{ text|lower|replace({ ' ': '-' }) }}"></a>
<h2>{{ text }}</h2>

View file

@ -0,0 +1,9 @@
{% if toc %}
<ul>
{% for title in toc %}
<li>
<a href="#{{ title|lower|replace({ ' ': '-' }) }}">{{ title }}</a>
</li>
{% endfor %}
</ul>
{% endif %}

View file

@ -16,6 +16,8 @@
</div>
<div class="markdown">
{% include "post/table-of-contents" with { toc: page.toc } only %}
{{ parent() }}
</div>