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 ```toml
[extra] [extra]
sections = [ sections = [
"Usage", # Section 1 "Usage", # Section 1
"Extra" # Section 2 "Markdown", # Section 2
"Advanced" # Section 3
] ]
``` ```

View File

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

View File

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