Page-filled form fields, links to entries, entry JSON-LD, R2-optional dev
Forms: `values` on RenderForm / BuilderForm / useBuilderForm fills fields the
page knows (chosen product variant, category) — read-only <output>, in the
SSR HTML, sent and validated like any field. prepareBuilderForm (/rsc) is the
server half of RenderForm for client components whose values change in the
browser; publicForm is exported so projects stop copying it.
Links: buildLinkField({ relationTo: ['pages', 'categories', …] }) — a
polymorphic relation; resolveLinkHref builds /{locale}/{archive}/{entry} from
`archives`, which getLinkOptions in createContentHelpers fills from Site
Settings.
SEO: pageJsonLd.entries — the main JSON-LD node per content collection
instead of BlogPosting; buildProductJsonLd emits an Offer only for a real
price from the panel.
Pages: createPageRoute / createNotFoundPage pass isFirst to blocks, so the
first section carries the page's only h1.
Fixes: ipalEnvRules({ storage: true }) requires R2_* in production only
(development: optional, all or none); buildImagesConfig allows the app's own
media on localhost outside production.
Docs, CHANGELOG, PROGRAMISTA §6 (34–37), ipal-form and ipal-upgrade skills.
Tests: builderForm, links, drafts (entries + archives), seo, media, env.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
46d30d4ecd
commit
f809526f1d
@@ -19,6 +19,7 @@ import { createMarkdownRoute } from '../content/createMarkdownRenderer.js'
|
||||
import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'
|
||||
import { MARKDOWN_PREFIX, markdownHref } from '../content/markdownNegotiation.js'
|
||||
import { resolveRedirect as resolveRedirectRaw } from '../content/resolveRedirect.js'
|
||||
import { archiveFieldName } from '../content/types.js'
|
||||
import { createHealthRoute } from '../health/createHealthRoute.js'
|
||||
import { homeSlugFrom, resolveLink as resolveLinkRaw, resolveNav as resolveNavRaw, resolveSystemLinks } from '../links/resolveNav.js'
|
||||
import { createMcpRoute } from '../mcp/createMcpRoute.js'
|
||||
@@ -94,9 +95,30 @@ type CreateContentHelpersArgs = {
|
||||
summaryField?: string
|
||||
}
|
||||
|
||||
/** What an entry's own JSON-LD builder gets (PageJsonLdOptions.entries). */
|
||||
export type EntryJsonLdContext = {
|
||||
/** Archive page of the entry (title, slug). */
|
||||
archive: Record<string, unknown>
|
||||
/** Meta description (SEO tab or the site's description). */
|
||||
description?: string
|
||||
doc: Record<string, unknown>
|
||||
/** Absolute share-image URL. */
|
||||
image?: string
|
||||
locale: string
|
||||
siteName?: string
|
||||
/** Absolute canonical URL of the entry. */
|
||||
url: string
|
||||
}
|
||||
|
||||
export type PageJsonLdOptions = {
|
||||
/** BreadcrumbList (home › archive › page) from the real route. Default true. */
|
||||
breadcrumbs?: boolean
|
||||
/**
|
||||
* The main node per content collection, instead of the article (`entryType`):
|
||||
* `{ products: (ctx) => buildProductJsonLd({…}), categories: (ctx) => buildWebPageJsonLd({ type: 'CollectionPage', … }) }`.
|
||||
* Return null to emit no main node. Breadcrumbs and FAQ still follow.
|
||||
*/
|
||||
entries?: Record<string, (ctx: EntryJsonLdContext) => null | Record<string, unknown>>
|
||||
/** schema.org type of archive entries. Default 'BlogPosting'. */
|
||||
entryType?: 'Article' | 'BlogPosting' | 'NewsArticle'
|
||||
/**
|
||||
@@ -270,7 +292,10 @@ export function createContentHelpers({
|
||||
const image = meta.openGraph?.images?.[0]?.url
|
||||
const nodes: (null | Record<string, unknown>)[] = []
|
||||
|
||||
if (route.type === 'entry') {
|
||||
const entryNode = route.type === 'entry' ? opts.entries?.[route.collection] : undefined
|
||||
if (route.type === 'entry' && entryNode) {
|
||||
nodes.push(entryNode({ archive: route.archive, description: meta.description, doc, image, locale, siteName, url }))
|
||||
} else if (route.type === 'entry') {
|
||||
nodes.push(
|
||||
buildArticleJsonLd({
|
||||
type: opts.entryType ?? 'BlogPosting',
|
||||
@@ -572,8 +597,23 @@ export function createContentHelpers({
|
||||
|
||||
/** Options for resolveLinkHref / resolveLink / RenderForm `linkOptions` in this locale. */
|
||||
const getLinkOptions = async (locale: string): Promise<ResolveLinkHrefOptions> => {
|
||||
const homeSlug = await getHomeSlug(locale)
|
||||
return { config: needI18n('getLinkOptions'), locale, ...(homeSlug ? { homeSlug } : {}) }
|
||||
const settings = await getSettings(locale)
|
||||
const homeSlug = homeSlugFrom(settings)
|
||||
// Archive page per content collection → links to entries (categories, products…) resolve too.
|
||||
const archives = Object.fromEntries(
|
||||
(content?.collections ?? []).flatMap(({ slug }) => {
|
||||
const archive = (settings as Record<string, unknown>)[archiveFieldName(slug)]
|
||||
const archiveSlug = archive && typeof archive === 'object' ? (archive as { slug?: unknown }).slug : undefined
|
||||
return typeof archiveSlug === 'string' && archiveSlug ? [[slug, archiveSlug]] : []
|
||||
}),
|
||||
)
|
||||
return {
|
||||
config: needI18n('getLinkOptions'),
|
||||
locale,
|
||||
pagesSlug,
|
||||
...(homeSlug ? { homeSlug } : {}),
|
||||
...(Object.keys(archives).length ? { archives } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user