summaryrefslogtreecommitdiff
path: root/sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2025-09-13 15:01:06 -0600
committerAlejandro Soto <alejandro@34project.org>2025-09-13 15:01:06 -0600
commitf4fcda54638685899c730b3fa90a87d80d6dbef5 (patch)
tree0737e627cce304c3a9c4e757bc5f6571a7456091 /sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html
parentd8b9cf1f61cc07d625f1c37ccc28adfd58918416 (diff)
parent2c13119932765c6d788f08fb53abc244407c0d80 (diff)
Merge commit '6a7d3111b31e73fc66af5360149d41f690fbcaa4'
Diffstat (limited to 'sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html')
-rw-r--r--sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html b/sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html
new file mode 100644
index 0000000..18a3ab6
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html
@@ -0,0 +1,54 @@
+{% macro toc(page, header, language_strings="") %}
+
+{%- set toc_levels = page.extra.toc_levels | default(value=3) -%}
+
+{% if page.extra.toc_ignore_pattern %}
+ {%- set toc_ignore_pattern = page.extra.toc_ignore_pattern -%}
+{% endif %}
+
+<div class="toc-container">
+ {% if header %}
+ <h3>{{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}</h3>
+ {% endif %}
+
+ <ul>
+ {% for h1 in page.toc %}
+ {# Only render headers if there's no ignore pattern, or if the header text doesn't match the pattern. #}
+ {% if not toc_ignore_pattern or not (h1.title is matching(toc_ignore_pattern)) %}
+ <li><a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
+ {% if h1.children and toc_levels > 1 %}
+ <ul>
+ {% for h2 in h1.children %}
+ {% if not toc_ignore_pattern or not (h2.title is matching(toc_ignore_pattern)) %}
+ <li><a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
+ {% if h2.children and toc_levels > 2 %}
+ <ul>
+ {% for h3 in h2.children %}
+ {% if not toc_ignore_pattern or not (h3.title is matching(toc_ignore_pattern)) %}
+ <li><a href="{{ h3.permalink | safe }}">{{ h3.title }}</a>
+ {% if h3.children and toc_levels > 3 %}
+ <ul>
+ {% for h4 in h3.children %}
+ {% if not toc_ignore_pattern or not (h4.title is matching(toc_ignore_pattern)) %}
+ <li><a href="{{ h4.permalink | safe }}">{{ h4.title }}</a></li>
+ {% endif %}
+ {% endfor %}
+ </ul>
+ {% endif %}
+ </li>
+ {% endif %}
+ {% endfor %}
+ </ul>
+ {% endif %}
+ </li>
+ {% endif %}
+ {% endfor %}
+ </ul>
+ {% endif %}
+ </li>
+ {% endif %}
+ {% endfor %}
+ </ul>
+</div>
+
+{% endmacro toc %}