feat: render CMS SEO metadata and refresh published page caches

This commit is contained in:
2026-10-11 18:05:47 +08:00
parent a8e2863cc4
commit 870b9b4282
19 changed files with 310 additions and 35 deletions
+22
View File
@@ -20,6 +20,28 @@ You can start editing the page by modifying `app/page.tsx`. The page auto-update
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## CMS SEO and Publish Cache
CMS routes read custom SEO title/description (falling back to standard Wagtail
SEO fields), canonical URL, social image, and JSON-LD. Explicit CMS SEO titles
are output without appending the site title template. Empty JSON-LD is omitted,
and script boundaries are escaped before output.
Deploy the backend API changes first, then build and restart the frontend.
No database migrations are required. Set `NEXT_PUBLIC_API_URL` to the public
CMS origin before building the frontend.
Set backend `FRONTEND_REVALIDATE_URL` to the frontend `/api/revalidate` endpoint.
Both services must use the same `REVALIDATE_SECRET`. All Wagtail page requests
share the `wagtail-pages` tag. Publishing expires this tag immediately, and the
next request fetches fresh data. This refreshes all page caches, including lists.
Snippet caches retain separate tags. Without a working webhook, the existing
60-second time-based revalidation remains the fallback.
Frontend tests: `node --test tests/seo.test.cjs`.
Backend tests (from the backend root):
`python -m pytest apps/core/tests.py -k "page_api_exposes_seo_fields or seo_image_serializer or notify_frontend_revalidate"`.
## Learn More
To learn more about Next.js, take a look at the following resources: