Fetch nav-tree fragment from blog, drop local menu_items query
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m2s

Navigation is now rendered by blog as an HTML fragment. This app
fetches it with its own app_name and path for correct highlighting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-24 11:39:39 +00:00
parent 93f830ff13
commit d1a6690cc3
2 changed files with 8 additions and 5 deletions

11
app.py
View File

@@ -3,7 +3,7 @@ import path_setup # noqa: F401 # adds shared/ to sys.path
from pathlib import Path
from quart import g, abort
from quart import g, abort, request
from jinja2 import FileSystemLoader, ChoiceLoader
from sqlalchemy import select
@@ -17,20 +17,23 @@ async def market_context() -> dict:
"""
Market app context processor.
- menu_items: direct DB query
- nav_tree_html: fetched from blog as fragment
- cart_count/cart_total: via cart service (includes calendar entries)
- cart: direct ORM query (templates need .product relationship)
"""
from shared.infrastructure.context import base_context
from shared.services.navigation import get_navigation_tree
from shared.services.registry import services
from shared.infrastructure.cart_identity import current_cart_identity
from shared.infrastructure.fragments import fetch_fragment
from shared.models.market import CartItem
from sqlalchemy.orm import selectinload
ctx = await base_context()
ctx["menu_items"] = await get_navigation_tree(g.s)
ctx["nav_tree_html"] = await fetch_fragment(
"blog", "nav-tree",
params={"app_name": "market", "path": request.path},
)
ident = current_cart_identity()

2
shared

Submodule shared updated: 0d40dfaeca...7e650a0ee3