Add nav-tree fragment: blog renders nav for all apps
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
Blog now provides a nav-tree fragment at /internal/fragments/nav-tree that accepts app_name and path params for correct aria-selected highlighting. Blog itself consumes this fragment alongside cart-mini and auth-menu in a single concurrent fetch_fragments() call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,11 @@
|
||||
|
||||
{# Desktop nav #}
|
||||
<nav class="hidden md:flex gap-4 text-sm ml-2 justify-end items-center flex-0">
|
||||
{% include '_types/root/_nav.html' %}
|
||||
{% if nav_tree_html %}
|
||||
{{ nav_tree_html | safe }}
|
||||
{% else %}
|
||||
{% include '_types/root/_nav.html' %}
|
||||
{% endif %}
|
||||
{# Auth menu — fetched from account app as fragment #}
|
||||
{% if auth_menu_html %}
|
||||
{{ auth_menu_html | safe }}
|
||||
|
||||
26
templates/fragments/nav_tree.html
Normal file
26
templates/fragments/nav_tree.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{# Nav-tree fragment — rendered by blog, consumed by all apps.
|
||||
Uses frag_app_name / frag_first_seg instead of request.path / app_name
|
||||
so the consuming app's context is reflected correctly.
|
||||
No hx-boost — cross-app nav links are full page navigations. #}
|
||||
{% set _app_slugs = {'cart': cart_url('/')} %}
|
||||
<div class="flex flex-col sm:flex-row sm:items-center gap-2 border-r border-stone-200 mr-2 sm:max-w-2xl"
|
||||
id="menu-items-nav-wrapper">
|
||||
{% from 'macros/scrolling_menu.html' import scrolling_menu with context %}
|
||||
{% call(item) scrolling_menu('menu-items-container', menu_items) %}
|
||||
{% set _href = _app_slugs.get(item.slug, blog_url('/' + item.slug + '/')) %}
|
||||
<a
|
||||
href="{{ _href }}"
|
||||
aria-selected="{{ 'true' if (item.slug == frag_first_seg or item.slug == frag_app_name) else 'false' }}"
|
||||
class="{{styles.nav_button_less_pad}}"
|
||||
>
|
||||
{% if item.feature_image %}
|
||||
<img src="{{ item.feature_image }}"
|
||||
alt="{{ item.label }}"
|
||||
class="w-8 h-8 rounded-full object-cover flex-shrink-0" />
|
||||
{% else %}
|
||||
<div class="w-8 h-8 rounded-full bg-stone-200 flex-shrink-0"></div>
|
||||
{% endif %}
|
||||
<span>{{ item.label }}</span>
|
||||
</a>
|
||||
{% endcall %}
|
||||
</div>
|
||||
Reference in New Issue
Block a user