We’ve decided to build our documentation site on Zola and it’s really cool so far, but I bumped into a problem: our structure for content is basically version/section/subsection/page and I’m struggling how to make global navigation for the current version. For the version picker, I simply used subsections of get_section('_index.md'), but I’m unsure how to provide versioned _index.md to my navigation.
What I need is basically:
get_section('1.0.0/_index.md') for version 1.0 of the documentation
get_section('1.1.0/_index.md') for 1.1.0
and so on
Is there any variable I can pass to get_section to make it work or do I have to hack section and/or page.ancestors?
I made a hacky first version work using all sorts of sorcery:
{% set current_section = current_path | as_str | split(pat="/") | first %}
{% if current_section %}
{% set section_array = [current_section | as_str, "_index.md"] %}
{% set section_path = section_array | join(sep='/') %}
{% else %}
{% set section_path = '_index.md' %}
{% endif %}
{% set section = get_section(path=section_path) %}
Being a designer / front-end person myself, I am having a “my code doesn’t work and I don’t know why” to “my code works and I don’t know why” moment, but it’s good enough for v1.0