diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-03 07:47:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-03 07:47:36 +0000 |
commit | 1f6a9795ed529247bb3370c5efeb009a81d30c8b (patch) | |
tree | b0bb57ba2ba39cb69b7426cbc73632d1d0186c79 /docs/theme/Toc.jinja | |
parent | Adding debian version 0.45+dfsg-1. (diff) | |
download | jinjax-1f6a9795ed529247bb3370c5efeb009a81d30c8b.tar.xz jinjax-1f6a9795ed529247bb3370c5efeb009a81d30c8b.zip |
Merging upstream version 0.46.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs/theme/Toc.jinja')
-rw-r--r-- | docs/theme/Toc.jinja | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/docs/theme/Toc.jinja b/docs/theme/Toc.jinja new file mode 100644 index 0000000..2670b62 --- /dev/null +++ b/docs/theme/Toc.jinja @@ -0,0 +1,45 @@ +{# def toc, page #} + +{% macro render_page(url, title) %} +{% if url != "/" -%} +<div class="page {{ 'active' if page.url == url else '' }}"> + <a href="{{ url }}#">{{ title }}</a> +</div> +{%- endif %} +{% endmacro %} + + +{% macro render_collapsable(title, children) %} +<details open> + {% if title %}<summary>{{ title }}</summary>{% endif %} + {{ render_children(children) }} +</details> +{% endmacro %} + + +{% macro render_section(title, children) %} +<section open> + {% if title %}<h2>{{ title }}</h2>{% endif %} + {{ render_children(children) }} +</section> +{% endmacro %} + + +{% macro render_children(children, collapsable=True) %} + {%- for url, title, sub_children in children %} + {% if sub_children -%} + {% if collapsable -%} + {{ render_collapsable(title, sub_children) }} + {%- else -%} + {{ render_section(title, sub_children) }} + {%- endif %} + {%- else -%} + {{ render_page(url, title) }} + {%- endif %} + {%- endfor %} +{% endmacro %} + + +<div {{ attrs.render(class="cd-toc", data_component="Toc") }}> + {{ render_children(toc, collapsable=False) }} +</div>
\ No newline at end of file |