Block library: fixes from the first visual test on the reference site

- CMSLink: a link that wraps content (a logo, a card) and leads nowhere keeps the
  content — an empty link group ({ type: 'internal' }) no longer hides logos
- entryList: field `collection` → `entryCollection` (Mongoose reserves
  `collection`; unreleased, snapshot updated) + a test against reserved names
- post template starts with a page hero holding the title (the page's h1)
- legal and cookie policy templates set noindex: true (AGENT.md §0c)
- hero background: a full bg-overlay scrim under the text
- MediaValue accepts any object (generated Media types fit without a cast)
- contact: Turnstile renders dark in an inverted section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 15:03:39 +01:00
co-authored by Claude Opus 5.5
parent 51f80cea13
commit 29ede3ad4b
12 changed files with 85 additions and 30 deletions
@@ -36,7 +36,15 @@ export async function ContactBlock(props: LibraryBlockProps<ContactBlockData>) {
])
const formEl = (
<div className={c.form}>
<RenderForm action={ctx.sendForm} classNames={ctx.formClassNames} form={form as never} linkOptions={linkOptions} locale={locale} texts={texts as BuilderFormTexts} />
<RenderForm
action={ctx.sendForm}
classNames={ctx.formClassNames}
form={form as never}
linkOptions={linkOptions}
locale={locale}
texts={texts as BuilderFormTexts}
turnstileTheme={settings?.background === 'inverted' ? 'dark' : 'page'}
/>
</div>
)
const aside = withDetails && (content || details.length) ? (
@@ -7,8 +7,8 @@ import { cx, parts } from '../../ui/cx.js'
import { TitleLink } from '../../ui/TitleLink.js'
export type EntryListBlockData = {
collection?: null | string
entries?: { relationTo: string; value: unknown }[] | null
entryCollection?: null | string
limit?: null | number
mode?: null | string
} & BaseBlockData
@@ -36,7 +36,7 @@ type Row = { card: EntryCard; collection: string; doc: Record<string, unknown> }
/** The latest entries of a collection, or entries chosen by hand; each card links to its entry. */
export async function EntryListBlock(props: LibraryBlockProps<EntryListBlockData>) {
const { classNames, collection, ctx, entries, header, isFirst, limit, links, locale, mode, settings, ui, variant } = props
const { classNames, ctx, entries, entryCollection: collection, header, isFirst, limit, links, locale, mode, settings, ui, variant } = props
const toCard = ctx.entryCard ?? defaultEntryCard
let docs: { collection: string; doc: Record<string, unknown> }[] = []
if (mode === 'selected') {
@@ -19,7 +19,8 @@ export const buildEntryListBlock = defineLibraryBlock<EntryListOptions>({
const latest = (_: unknown, s: { mode?: string } | undefined) => s?.mode !== 'selected'
return [
{
name: 'collection',
// Not `collection`: Mongoose reserves that path name.
name: 'entryCollection',
type: 'select',
defaultValue: collections[0]?.value,
label: adminText('Show', 'Pokaż'),
@@ -10,7 +10,7 @@ export type HeroBlockData = { media?: MediaValue; poster?: MediaValue } & BaseBl
export const HERO_PARTS = {
background: 'relative isolate flex min-h-[var(--ipal-hero-min-h)] items-center overflow-hidden',
backgroundMedia: 'absolute inset-0 -z-10 h-full w-full object-cover',
backgroundOverlay: 'absolute inset-0 -z-10 bg-linear-to-t from-overlay to-transparent',
backgroundOverlay: 'absolute inset-0 -z-10 bg-overlay',
centered: 'mx-auto max-w-narrow text-center',
media: 'h-auto w-full rounded-media object-cover',
page: 'max-w-measure',
+1 -1
View File
@@ -10,7 +10,7 @@ export type SectionHeaderData = { eyebrow?: null | string; heading?: null | stri
export type SectionSettingsData = { [key: string]: unknown; anchor?: null | string; background?: null | string }
/** An upload as stored (an id) or populated (a media document). */
export type MediaValue = null | number | Record<string, unknown> | string | undefined
export type MediaValue = null | number | object | string | undefined
export type LinkData = LinkValue | null | undefined
+7 -1
View File
@@ -27,7 +27,13 @@ export type TemplateOptions = {
}
/** A page for `seed.upsertBySlug('pages', [...])`. */
export type TemplatePage = { layout: Record<string, unknown>[]; slug: TemplateValue; title: TemplateValue }
export type TemplatePage = {
layout: Record<string, unknown>[]
/** Set on legal pages (AGENT.md §0c) — the `noindex` field of buildNoindexField; a collection without it ignores it. */
noindex?: boolean
slug: TemplateValue
title: TemplateValue
}
/** The templates' own page slugs, by page. */
export const TEMPLATE_SLUGS = {
+14 -9
View File
@@ -15,6 +15,9 @@ const cta = (options?: TemplateOptions) => ({
variant: 'band',
})
/** Legal pages stay out of search results (AGENT.md §0c); set `noindex: false` on the result to change it. */
const noindex = (page: TemplatePage): TemplatePage => ({ ...page, noindex: true })
const items = (n: number, make: (i: number) => Record<string, unknown>) => Array.from({ length: n }, (_, i) => make(i + 1))
/** Home: hero, logos, features, text and image, key figures, testimonials, FAQ, call to action. */
@@ -81,11 +84,13 @@ export function blogIndex(options?: TemplateOptions): TemplatePage {
return buildTemplate('blogIndex', { slug: tx('blog', 'blog'), title: tx('Blog', 'Blog') }, [pageHero(tx('Blog', 'Blog'), fill('what the posts are about', 'o czym są wpisy')), cta(options)], options)
}
/** Post body for a posts collection with a `layout` field: text with a table of contents, more posts, call to action. */
/** Post body for a posts collection with a `layout` field: the title as the page header (h1), text with a table of contents, more posts, call to action. */
export function post(options?: TemplateOptions): TemplatePage {
return buildTemplate('post', { slug: fill('post-address', 'adres-wpisu'), title: fill('post title', 'tytuł wpisu') }, [
const title = options?.title ?? fill('post title', 'tytuł wpisu')
return buildTemplate('post', { slug: fill('post-address', 'adres-wpisu'), title }, [
{ blockType: 'hero', header: header(title as Record<string, string>), variant: 'page' },
{ blockType: 'richText', content: richText(fill('post text', 'treść wpisu')), tableOfContents: { label: tx('Contents', 'Spis treści'), show: true }, variant: 'narrow' },
{ blockType: 'entryList', collection: 'posts', header: header(tx('Read also', 'Przeczytaj też')), limit: 3, mode: 'latest', variant: 'cards' },
{ blockType: 'entryList', entryCollection: 'posts', header: header(tx('Read also', 'Przeczytaj też')), limit: 3, mode: 'latest', variant: 'cards' },
cta(options),
], options)
}
@@ -95,10 +100,10 @@ const LEGAL = {
termsOfService: { slug: tx('terms', 'regulamin'), title: tx('Terms of service', 'Regulamin') },
}
/** A legal page (privacy policy, terms): header and text with a table of contents. Structure only — the wording comes from the client. */
/** A legal page (privacy policy, terms): header and text with a table of contents, `noindex`. Structure only — the wording comes from the client. */
export function legal(role: keyof typeof LEGAL, options?: TemplateOptions): TemplatePage {
const { slug, title } = LEGAL[role]
return buildTemplate(role, { slug, title }, [
return noindex(buildTemplate(role, { slug, title }, [
pageHero(title),
{
blockType: 'richText',
@@ -109,15 +114,15 @@ export function legal(role: keyof typeof LEGAL, options?: TemplateOptions): Temp
tableOfContents: { label: tx('Contents', 'Spis treści'), show: true },
variant: 'narrow',
},
], options)
], options))
}
/** Cookie policy: header and text; put the cookie table (CookieTable) on it in your page view or own block. */
/** Cookie policy: header and text, `noindex`; put the cookie table (CookieTable) on it in your page view or own block. */
export function cookiePolicy(options?: TemplateOptions): TemplatePage {
return buildTemplate('cookiePolicy', { slug: tx('cookie-policy', 'polityka-cookies'), title: tx('Cookie policy', 'Polityka cookies') }, [
return noindex(buildTemplate('cookiePolicy', { slug: tx('cookie-policy', 'polityka-cookies'), title: tx('Cookie policy', 'Polityka cookies') }, [
pageHero(tx('Cookie policy', 'Polityka cookies')),
{ blockType: 'richText', content: richText(fill('cookie policy text from the client', 'treść polityki cookies od klienta')), tableOfContents: { show: false }, variant: 'narrow' },
], options)
], options))
}
/** 404: a small header with a button home. */
+7 -4
View File
@@ -11,7 +11,7 @@ import { cx } from './cx.js'
export type ResolveLink = (link: LinkData, locale: string) => null | Promise<null | ResolvedLink> | ResolvedLink
export type CMSLinkProps = {
/** For a link that wraps something (a card, an image): the content instead of the label. */
/** For a link that wraps something (a card, an image): the content instead of the label — shown without a link when the link leads nowhere. */
children?: ReactNode
className?: string
link: LinkData
@@ -28,9 +28,12 @@ export async function CMSLink({
locale,
resolve,
}: { buttonClass?: (appearance?: null | string) => string; Link?: LinkComponent; resolve: ResolveLink } & CMSLinkProps) {
const l = await resolve(link, locale)
const content = children ?? l?.label
if (!l || !content) {return null}
const l = link ? await resolve(link, locale) : null
// A link that wraps something (a logo, a card) and leads nowhere — an empty link group, a deleted page —
// keeps its content as it is; a plain text link without a target renders nothing.
if (!l) {return children ?? null}
const content = children ?? l.label
if (!content) {return null}
const cls = cx(buttonClass(l.appearance), className) || undefined
return (
<Anchor className={cls} href={l.href} internal={l.internal} Link={Link} targetProps={l.targetProps}>