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:
Radosław Smoliński
2026-10-19 19:38:28 +02:00
co-authored by Claude Opus 5.5
parent 46d30d4ecd
commit f809526f1d
31 changed files with 551 additions and 54 deletions
+6 -8
View File
@@ -20,7 +20,7 @@ export type BuildLinkFieldOptions = {
/** Field name. Default 'link'. */
name?: string
/** Collection the "Page" option points at. Default 'pages'. */
relationTo?: string
relationTo?: readonly string[] | string
required?: boolean
/** Upload collection for "File" links (PDF, documents). Default 'media'. */
uploadTo?: string
@@ -50,6 +50,7 @@ export function buildLinkField({
required = false,
uploadTo = 'media',
}: BuildLinkFieldOptions = {}): GroupField {
const pageAdmin = { condition: (_: unknown, s: SiblingWithType) => s?.type === 'internal' }
const fields: Field[] = [
{
type: 'row',
@@ -73,13 +74,10 @@ export function buildLinkField({
},
],
},
{
name: 'page',
type: 'relationship',
admin: { condition: (_: unknown, s: SiblingWithType) => s?.type === 'internal' },
relationTo,
required,
},
// One collection → plain relation; several (pages + content entries) → polymorphic.
typeof relationTo === 'string'
? { name: 'page', type: 'relationship', admin: pageAdmin, relationTo, required }
: { name: 'page', type: 'relationship', admin: pageAdmin, relationTo: [...relationTo], required },
{
name: 'url',
type: 'text',
+22 -3
View File
@@ -1,5 +1,6 @@
import type { I18nConfig } from '../i18n/index.js'
import { buildEntryPath } from '../content/paths.js'
import { buildLocalizedPath } from '../i18n/index.js'
/**
@@ -32,6 +33,12 @@ export type LinkValue = {
}
export type ResolveLinkHrefOptions = {
/**
* Archive page slug per content collection in this locale (`{ categories: 'kategorie' }`) —
* links to entries (buildLinkField({ relationTo: ['pages', 'categories'] })) become
* /{locale}/{archive}/{entry}. getLinkOptions in lib/content fills it from Site Settings.
*/
archives?: Record<string, string>
config: I18nConfig
/**
* Slug(s) of the homepage so it collapses to /{locale}. A per-locale map or a
@@ -39,6 +46,8 @@ export type ResolveLinkHrefOptions = {
*/
homeSlug?: Record<string, string> | string
locale: string
/** The pages collection — links to it are page paths, other collections are entries. Default 'pages'. */
pagesSlug?: string
}
/**
@@ -54,7 +63,7 @@ export type ResolveLinkHrefOptions = {
*/
export function resolveLinkHref(
link: LinkValue | null | undefined,
{ config, homeSlug, locale }: ResolveLinkHrefOptions,
{ archives, config, homeSlug, locale, pagesSlug = 'pages' }: ResolveLinkHrefOptions,
): null | string {
if (!link) {return null}
@@ -69,12 +78,22 @@ export function resolveLinkHref(
return null
}
// internal (default)
const page = link.page
// internal (default) — a page, or (polymorphic relation) an entry of a content collection
let page = link.page
let collection = pagesSlug
if (page && typeof page === 'object' && 'relationTo' in page && 'value' in page) {
collection = String((page as { relationTo: unknown }).relationTo)
page = (page as { value: unknown }).value
}
if (!page || typeof page !== 'object') {return null}
const slug = (page as { slug?: unknown }).slug
if (typeof slug !== 'string' || !slug) {return null}
if (collection !== pagesSlug) {
const archiveSlug = archives?.[collection]
return archiveSlug ? buildEntryPath({ archiveSlug, entrySlug: slug, locale }) : null
}
return (
buildLocalizedPath({
config,