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
+26 -3
View File
@@ -1,6 +1,8 @@
type RemotePattern = { hostname: string; pathname?: string; port?: string; protocol?: 'http' | 'https' }
export type ImagesConfig = {
/** Development only: lets next/image optimize files served by the app itself on localhost. */
dangerouslyAllowLocalIP?: boolean
formats: ('image/avif' | 'image/webp')[]
minimumCacheTTL: number
remotePatterns: RemotePattern[]
@@ -11,15 +13,20 @@ export type ImagesConfig = {
* - AVIF first, WebP fallback — ~20–50 % smaller than JPEG at the same quality;
* - remotePatterns for the media domain (R2_PUBLIC_URL) so next/image may
* optimize R2 files — otherwise it refuses them;
* - optimized images cached for 31 days (uploads get new names when replaced).
* - optimized images cached for 31 days (uploads get new names when replaced);
* - outside production, media served by the app itself (`/api/media/file/**` on
* NEXT_PUBLIC_SERVER_URL — local disk, no R2), including localhost, which
* Next 16 otherwise refuses as a private IP.
*
* import { buildImagesConfig } from '@intecion/ipal-kit'
* export default withPayload({ images: { ...buildImagesConfig(), /* your overrides *\/ } })
*/
export function buildImagesConfig({
extraHosts = [],
production = process.env.NODE_ENV === 'production',
publicUrl = process.env.R2_PUBLIC_URL,
}: { extraHosts?: string[]; publicUrl?: string } = {}): ImagesConfig {
serverUrl = process.env.NEXT_PUBLIC_SERVER_URL,
}: { extraHosts?: string[]; production?: boolean; publicUrl?: string; serverUrl?: string } = {}): ImagesConfig {
const remotePatterns: RemotePattern[] = []
if (publicUrl && /^https?:\/\//i.test(publicUrl)) {
const u = new URL(publicUrl)
@@ -31,5 +38,21 @@ export function buildImagesConfig({
})
}
for (const host of extraHosts) {remotePatterns.push({ hostname: host, protocol: 'https' })}
return { formats: ['image/avif', 'image/webp'], minimumCacheTTL: 60 * 60 * 24 * 31, remotePatterns }
let localMedia = false
if (!production && serverUrl && /^https?:\/\//i.test(serverUrl)) {
const u = new URL(serverUrl)
remotePatterns.push({
hostname: u.hostname,
protocol: u.protocol.replace(':', '') as 'http' | 'https',
...(u.port ? { port: u.port } : {}),
pathname: '/api/media/file/**',
})
localMedia = /^(?:localhost|127\.|10\.|192\.168\.|\[::1\])/.test(u.hostname)
}
return {
formats: ['image/avif', 'image/webp'],
minimumCacheTTL: 60 * 60 * 24 * 31,
remotePatterns,
...(localMedia ? { dangerouslyAllowLocalIP: true } : {}),
}
}