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
@@ -1,6 +1,8 @@
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { buildSectionHeaderField, buildSectionSettingsField } from '../src/modules/blocks/sectionFields.js'
|
||||
import { buildLinkField } from '../src/modules/links/buildLinkField.js'
|
||||
import { resolveLinkHref } from '../src/modules/links/resolveLinkHref.js'
|
||||
import { homeSlugFrom, resolveLink, resolveNav } from '../src/modules/links/resolveNav.js'
|
||||
|
||||
const config = { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'PL' }, { code: 'en', label: 'EN' }] } as const
|
||||
@@ -104,3 +106,19 @@ describe('resolveSystemLinks', () => {
|
||||
expect(resolveSystemLinks(null, opts)).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('links to content entries (polymorphic page relation)', () => {
|
||||
test('buildLinkField with several collections makes a polymorphic relation', () => {
|
||||
const field = buildLinkField({ relationTo: ['pages', 'categories'] })
|
||||
const page = JSON.stringify(field.fields)
|
||||
expect(page).toContain('"relationTo":["pages","categories"]')
|
||||
})
|
||||
|
||||
test('an entry resolves under its archive page; a page stays a page; no archive → null', () => {
|
||||
const entry = { type: 'internal' as const, page: { relationTo: 'categories', value: { slug: 'pierscionki' } } }
|
||||
const archives = { categories: 'kategorie' }
|
||||
expect(resolveLinkHref(entry, { archives, config, locale: 'pl' })).toBe('/pl/kategorie/pierscionki')
|
||||
expect(resolveLinkHref({ type: 'internal', page: { relationTo: 'pages', value: { slug: 'kontakt' } } }, { archives, config, locale: 'pl' })).toBe('/pl/kontakt')
|
||||
expect(resolveLinkHref(entry, { config, locale: 'pl' })).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user