Make definition of docs sections optional #3
All checks were successful
Publish / publish (push) Successful in 18s

This commit is contained in:
david-swift 2025-04-13 15:32:31 +02:00
parent 81e310dc80
commit 3eb8ac49a3
3 changed files with 25 additions and 17 deletions

View File

@ -31,8 +31,9 @@ Use the following syntax:
```toml
[extra]
sections = [
"Usage", # Section 1
"Extra" # Section 2
"Usage", # Section 1
"Markdown", # Section 2
"Advanced" # Section 3
]
```

View File

@ -7,22 +7,26 @@
<div id="docs">
<ul>
{%- for page in section.pages %}
{%- if page.extra.section == 0 %}
<li>
<a class="{%- if slug == page.slug -%}active{%- endif -%}" href="{{ page.permalink | safe }}">{{ page.title }}</a>
</li>
{%- if page.extra.section %}
{%- if page.extra.section == 0 %}
{% include "partials/docs_toc_item.html" %}
{%- endif %}
{%- else %}
{% include "partials/docs_toc_item.html" %}
{%- endif %}
{%- endfor %}
{%- for section in section.extra.sections %}
{% set int_section = loop.index %}
<h3>{{ section }}</h3>
{%- for page in section.pages %}
{%- if page.extra.section == int_section %}
<li>
<a class="{%- if slug == page.slug -%}active{%- endif -%}" href="{{ page.permalink | safe }}">{{ page.title }}</a>
</li>
{%- endif %}
{%- endfor %}
{% endfor %}
{%- if section.extra.sections %}
{%- for section in section.extra.sections %}
{% set int_section = loop.index %}
<h3>{{ section }}</h3>
{%- for page in section.pages %}
{%- if page.extra.section %}
{%- if page.extra.section == int_section %}
{% include "partials/docs_toc_item.html" %}
{%- endif %}
{%- endif %}
{%- endfor %}
{% endfor %}
{%- endif %}
</ul>
</div>

View File

@ -0,0 +1,3 @@
<li>
<a class="{%- if slug == page.slug -%}active{%- endif -%}" href="{{ page.permalink | safe }}">{{ page.title }}</a>
</li>