Files
vue-seo-layer/app/composables/useSeoSite.ts
Jakub Zych 3abc986f42 feat: route report and drift check at server start
- the module writes #seo-routes (static paths and route patterns) from the
  resolved pages; options seo.routeReport, seo.pagination and
  seo.htmlSitemap reach the public runtime config
- seo-route-report: POST /registry/routes once per process with the
  route-report token, one retry after 60 s on failure, nothing without a
  token, with the layer off or with routeReport false
- seo-drift: one "[vue-seo-layer] drift:" warning per mismatch between
  the CMS's site answer (URL patterns, pagination, HTML sitemap paths)
  and the build
- GET /api/__seo__/site and useSeoSite()
- smoke grammar routereport and log, fixture registry route, drift run
2026-11-04 11:49:21 +01:00

23 lines
895 B
TypeScript

// The CMS's site answer (pagination form and segments, the home crumb, the
// HTML sitemap paths, the content URL patterns …), fetched once per page
// through GET /api/__seo__/site and shared by every caller on the server
// and in the browser (stable key, so the payload carries it to hydration).
// `data.value` is null with the layer off, with a backend before SEO
// v0.2.0 or with the backend down.
//
// const { data: site } = await useSeoSite()
import type { SeoSiteAnswer } from '../utils/types.ts'
export const SEO_SITE_KEY = 'seo-layer:site'
export function useSeoSite() {
return useFetch('/api/__seo__/site', {
key: SEO_SITE_KEY,
transform: (res: { site?: SeoSiteAnswer | null } | null): SeoSiteAnswer | null =>
res && typeof res === 'object' && res.site && typeof res.site === 'object' ? res.site : null,
default: () => null,
dedupe: 'defer',
})
}