Restore menu_items fallback, fix app slug URLs in nav fragment
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m6s

Keep get_navigation_tree() as fallback when nav-tree fragment fetch
fails. Also map all app slugs (market, events, federation, account)
to their proper cross-app URLs in the nav fragment template.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-24 11:49:20 +00:00
parent 288b3caf7f
commit e5b02f1c44
3 changed files with 12 additions and 2 deletions

4
app.py
View File

@@ -27,12 +27,16 @@ async def blog_context() -> dict:
- cart_mini_html / auth_menu_html / nav_tree_html: pre-fetched fragments - cart_mini_html / auth_menu_html / nav_tree_html: pre-fetched fragments
""" """
from shared.infrastructure.context import base_context from shared.infrastructure.context import base_context
from shared.services.navigation import get_navigation_tree
from shared.services.registry import services from shared.services.registry import services
from shared.infrastructure.cart_identity import current_cart_identity from shared.infrastructure.cart_identity import current_cart_identity
from shared.infrastructure.fragments import fetch_fragments from shared.infrastructure.fragments import fetch_fragments
ctx = await base_context() ctx = await base_context()
# Fallback for _nav.html when nav-tree fragment fetch fails
ctx["menu_items"] = await get_navigation_tree(g.s)
# Cart data via service (replaces cross-app HTTP API) # Cart data via service (replaces cross-app HTTP API)
ident = current_cart_identity() ident = current_cart_identity()
summary = await services.cart.cart_summary( summary = await services.cart.cart_summary(

2
shared

Submodule shared updated: 7e650a0ee3...ab674ada31

View File

@@ -2,7 +2,13 @@
Uses frag_app_name / frag_first_seg instead of request.path / app_name Uses frag_app_name / frag_first_seg instead of request.path / app_name
so the consuming app's context is reflected correctly. so the consuming app's context is reflected correctly.
No hx-boost — cross-app nav links are full page navigations. #} No hx-boost — cross-app nav links are full page navigations. #}
{% set _app_slugs = {'cart': cart_url('/')} %} {% set _app_slugs = {
'cart': cart_url('/'),
'market': market_url('/'),
'events': events_url('/'),
'federation': federation_url('/'),
'account': account_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" <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"> id="menu-items-nav-wrapper">
{% from 'macros/scrolling_menu.html' import scrolling_menu with context %} {% from 'macros/scrolling_menu.html' import scrolling_menu with context %}