adidoks
adidoks copied to clipboard
Hardcoded `blog` and `docs` sections
In {blog,docs}/{section,page}.html
templates docs and blog values are hardcoded.
It makes reusing these templates in other sections problematic.
It's possible to change
{% set current_section = "docs" %}
to
{% set current_section = current_path | split(pat="/") | nth(n=1) -%}
But I'm not sure if it's going to play well with base urls with extra path like https://exmlp.cm/docs/
.
In case it's fine, I'll file a PR. If not, we have to look for a better solution.
Zola docs states
current_path
: the path (full URL withoutbase_url
) of the current page, always starting with a/
which means we should be fine, but I'd like to deploy and test it.
Scratch that.
It looks like a change to the base.html
template can be a more general solution.
{% block header -%}
{% if current_path -%}
{% set current_section = current_path | split(pat="/") | nth(n=1) -%}
{% else -%}
{% set current_section = '/' -%}
{% endif -%}
{{ macros_header::header(current_section=current_section)}}
{% endblock header -%}
Good job! If you have finished the code of this part, you could pull a request. Thanks.
My solution to this, is simply to override the template. Hopefully, it will be a dynamic value in the future.