diff options
author | ADRN <adrien@luxeylab.net> | 2024-12-08 15:16:03 +0100 |
---|---|---|
committer | Marion <marionz@deuxfleurs.fr> | 2024-12-08 17:34:59 +0100 |
commit | 953a3593f90377a806b05407834aa3056a85dc0e (patch) | |
tree | 89e3515bacdf110c61bab69b97eff2be058c9be6 /templates/_macros.html | |
parent | 322457d8e58c3dffe9f42931deebfd87be779d87 (diff) | |
download | guide.deuxfleurs.fr-953a3593f90377a806b05407834aa3056a85dc0e.tar.gz guide.deuxfleurs.fr-953a3593f90377a806b05407834aa3056a85dc0e.zip |
feat(nav): soulignage de la section active dans la topbar
Diffstat (limited to 'templates/_macros.html')
-rw-r--r-- | templates/_macros.html | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/templates/_macros.html b/templates/_macros.html index 8286314..63d6c98 100644 --- a/templates/_macros.html +++ b/templates/_macros.html @@ -1,25 +1,32 @@ {% macro render_header() %} -{% set section = get_section(path="_index.md") %} +{% set root_section = get_section(path="_index.md") %} +{% set active_section = "" %} +{% if page and page.components %} + {% set active_section = page.components[0] %} +{% elif section and section.components %} + {% set active_section = section.components[0] %} +{% endif %} - -<a href="{{ section.permalink }}"> +<a href="{{ root_section.permalink }}"> <div class="logo"> <img src="{{ get_url(path=config.extra.juice_logo_path) }}" alt="logo"> {{ config.extra.juice_logo_name }} </div> </a> - <nav> <ul> - {% for subpath in section.subsections %} + {% for subpath in root_section.subsections %} {% set sub = get_section(path=subpath) %} + {% set is_active = sub.components[0] == active_section %} {% if not 'hide_from_menu' in sub.extra or not sub.extra.hide_from_menu %} - <li><a class="nav-item text" href="{{ sub.permalink }}">{{ sub.title }}</a></li> + <li> + <a class="nav-item text{% if is_active %} active{% endif %}" href="{{ sub.permalink }}">{{ sub.title }}</a> + </li> {% endif %} {% endfor %} {% if config.extra.juice_extra_menu %} {% for menu in config.extra.juice_extra_menu %} - <li><a class="nav-item text" href="{{ menu.link }}">{{ menu.title }}</a></li> + <li><a class="nav-item text" href="{{ menu.link }}">{{ menu.title }}</a></li> {% endfor %} {% endif %} </ul> |