aaranxu / adidoks

AdiDoks is a mordern documentation theme, which is a port of the Hugo theme Doks for Zola.
https://adidoks.org
MIT License
228 stars 82 forks source link

Hardcoded `blog` and `docs` sections #4

Open ejiektpobehuk opened 3 years ago

ejiektpobehuk commented 3 years ago

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.

ejiektpobehuk commented 3 years ago

Zola docs states

current_path: the path (full URL without base_url) of the current page, always starting with a /

which means we should be fine, but I'd like to deploy and test it.

ejiektpobehuk commented 3 years ago

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 -%}
aaranxu commented 3 years ago

Good job! If you have finished the code of this part, you could pull a request. Thanks.

azzamsa commented 2 years ago

My solution to this, is simply to override the template. Hopefully, it will be a dynamic value in the future.