Closed curioustolearn closed 3 years ago
Hi, thanks for the warm words. Sorry if I got you wrhong. Code you mentioned is about table of content. It's not subsections. Easy docs have pretty flat arch. You could have only articles inside one folder. Anyway, right now TOC collect hearders from h2 to h4. I'm not sure how it would look like, but If you need more nested TOC - you could add h5 too:
{% for h2 in page.toc %}
{% set_global header_count = header_count + 1 %}
{% for h3 in h2.children %}
{% set_global header_count = header_count + 1 %}
{% for h4 in h3.children %}
{% set_global header_count = header_count + 1 %}
{% for h5 in h4.children %}
{% set_global header_count = header_count + 1 %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
Yes, after writing my post, I looked at the demo site more closely. I sort of realized that the code I posted/quoted was for the headers within a markdown file. I was looking for the folding
(if that is the right ward) in the navigation section. For example, I have a structure like the one below. I was wondering if Software
could appear in TOC section with ability to fold/unfold it just like Bookmarks
and Postgres
do? Thanks again for your response.
content
├── Bookmarks
│ ├── Recipes.md
│ ├── _index.md
│ └── software
│ |── _index.md
│ |── programming_language_comparisons.md
├── Postgres
│ ├── _index.md
│ ├── backup_restore.md
│ └── installation_setup.md
└── _index.md
Adding the following code within the <ul class="subtree"> ...</ul>
section of your index.html
template worked to get a second level of subsections.
{% for p2 in subsection.subsections %}
<div style="margin-left:1em;">
{% set subsection2 = get_section(path=p2) %}
<input class="tree-toggle" type="checkbox" id="{{ subsection2.title | slugify }}"
{% if current_path is starting_with(subsection2.path) %}checked{% endif %} />
<label class="tree-toggle-label" for="{{ subsection2.title | slugify }}">
{{ subsection2.title }}
</label>
<ul class="subtree">
{% for page2 in subsection2.pages %}
<li {% if current_path == page2.path %}class="active"{% endif %}>
<a href="{{page2.permalink | safe }}">{{page2.title}}</a>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
Hi,
Thank you for a clean and nice theme for Zola. I had a help request. Is it possible to get the nested subsections in the nav bar? I am new to Zola and have not used Tera before. So if you could guide as to where I need to make a change to get nested subsection in the nav bar, that would be very helpful. I looked at
nav block
in your theme'sindex.html
template. The following lines suggest that I should see subsections up to 4 levels (am I reading this wrong?). But I just see the top level sections and not the second level sections. Can you direct me where to look for this?Thank you.