Add page-level SEO metadata support to @weaverse/hydrogen and @weaverse/schema#453
Conversation
|
Claude finished @hieuht09's task in 2m 22s —— View job Code Review: PR #453 — Page-level SEO metadata support
Overall the implementation is clean, additive-only, and correct. No breaking changes, the logic is sound, and the JSDoc is useful. A few design choices are worth discussing.
|
| Severity | Issue |
|---|---|
| Medium | robots always emitted when any SEO object is present — could silently override noindex in stacked meta setups |
| Minor | og:url not emitted from canonicalUrl |
| Minor | 'product' is non-standard og:type — no JSDoc warning |
| Minor | og:image absolute URL requirement is implicit / undocumented |
| Nit | getWeaverseSeoMeta structural discriminant is fragile |
The robots-always-wins behavior is the one most likely to surprise theme authors; the rest are low-impact quality improvements. The code is otherwise well-structured, the JSDoc is useful, and the additive-only approach is correct.
What
Adds page-level SEO support so themes can render meta tags from SEO data published by Weaverse Builder (the
PageSeosidecar on the public content payload).Changes
@weaverse/schema— type-only contractsrc/page-seo.ts(new):PageSEODatainterface mirroring the builder's nested DTO, plusOpenGraphTypeandTwitterCardTypeunions.builder/app/schemas/page-seo.ts(pageSeoSchema). The SDK trusts the builder payload and does not re-validate at runtime. Field names must stay in sync.src/index.ts.@weaverse/hydrogen— runtimesrc/seo.ts(new):formatMetaDescriptors(seo)— pure, synchronous, tree-shakeable. ConvertsPageSEOData→ React RouterMetaDescriptor[]. Mapstitle,description,keywords,canonicalUrl,openGraph.*(og:*),twitter.*(twitter:*). Empty/missing fields are filtered out so they don't override earlier SEO sources (e.g. HydrogengetSeoMeta).robotsis always emitted (defaultsindex,follow) for a deterministic last word on indexing.getWeaverseSeoMeta(data)— null-safe accessor that pullspage.seoout ofWeaverseLoaderData/HydrogenPageDataand returnsMetaDescriptor[].src/types.ts:HydrogenPageDatagains optionalseo?: PageSEOData | null.null= page has noPageSeorow;undefined= pre-feature revision snapshot. Themes treat both as "no Weaverse override".src/index.ts: re-exports./seo.Usage