diff --git a/bin/ipal-blocks.mjs b/bin/ipal-blocks.mjs old mode 100644 new mode 100755 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 73c78b5..10c5b18 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -80,6 +80,11 @@ fifteen ready page sections and ten page templates. A new site in one command: ` Type `CookieButtonProps`. ### Fixed +- **Block library — headings and the LCP image** (found by `ipal-doctor` live-seo on the archive pages): item headings + follow the section — `h3` under a section heading, `h2` when the block shows none (an entry list under the page header + no longer jumps `h1` → `h3`); override with `createBlockRegistry({ itemHeadings: { entryList: 'h3' } })`. The first + image of the block that leads the page loads eagerly with high priority — `createPageRoute` now passes `firstImage` + ("no block before this one shows an image", `blockPosition`) next to `isFirst`; `priorityImage: false` turns it off. - **Sitemap, llms.txt, the site index (MCP `list_pages`), search (`searchContent`, the search route, MCP `search_content`):** the page assigned as the 404 page is no longer listed — it answers 404 at its own address (`unlistedPageIds(settings)`). A 404 page that is also the homepage stays. @@ -88,7 +93,8 @@ fifteen ready page sections and ten page templates. A new site in one command: ` 400. With R2 nothing changes; a production build on localhost still never opens private IPs. - **`fillGlobal`:** a choice field (select, radio, checkbox, number, date) still at its `defaultValue` counts as empty, so e.g. Theme → `defaultTheme: 'system'` can be seeded over the stored default `light`. Text is never - overwritten, even when it equals a default. + overwritten, even when it equals a default. A field already holding + exactly the seeded value is not rewritten (`skip (exists)`), so a seed of defaults stays idempotent. - **Docs:** `LanguageSwitcher` with `renderLabel` needs a `'use client'` wrapper (i18n.md, ipal-site). ### Changed diff --git a/docs/agent/reference-site/INDEX.md b/docs/agent/reference-site/INDEX.md index 677d79f..e9f281b 100644 --- a/docs/agent/reference-site/INDEX.md +++ b/docs/agent/reference-site/INDEX.md @@ -81,16 +81,6 @@ legacy-peer-deps=true "until": "2026-11-30", "reason": "Follow-up for the reference-site track: three pages per language have no own meta description and fall back to the site description; the seed should give each page one" }, - "live-seo:heading-levels-skipped": { - "off": true, - "until": "2026-11-30", - "reason": "Follow-up for the block-library track: entryList cards use h3 with no h2 on the archive pages (h1 → h3)" - }, - "live-seo:first-image-not-prioritised-lcp": { - "off": true, - "until": "2026-11-30", - "reason": "Follow-up for the block-library track: on the archive pages the first image is an entryList card, which is not marked priority" - }, "live-seo:thin-pages-words": { "off": true, "until": "2026-11-30", diff --git a/docs/agent/skills/ipal-reference/resources/api.md b/docs/agent/skills/ipal-reference/resources/api.md index 4ec4ddc..c789cd2 100644 --- a/docs/agent/skills/ipal-reference/resources/api.md +++ b/docs/agent/skills/ipal-reference/resources/api.md @@ -104,6 +104,7 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT | Export | Import from | What it does / when | |---|---|---| | `RenderBlocks` | `@intecion/ipal-kit/rsc` | Server block renderer: `{ blocks, components, enhanceProps? }` — each block through a `blockType → component` map, skips unknown ones, no extra markup. Do not write your own loop over blocks. Nested blocks render their own `RenderBlocks` (do not pass the map as a prop). | +| `blockPosition({ allBlocks, index })`, `blockHasImage(data)` | `@intecion/ipal-kit` | `{ isFirst, firstImage }` for a block — first section (page `h1`) and "no earlier block shows an image" (LCP image); createPageRoute passes both, spread it in your own `enhanceProps`. | | `buildSectionHeaderField(opts?)` | `@intecion/ipal-kit` | `header` field group (eyebrow, heading, intro — localized) for every section block; `interfaceName` `SectionHeaderData`. Options: `name`, `fields`, `interfaceName`. | | `buildSectionSettingsField(opts?)` | `@intecion/ipal-kit` | `settings` group in the block sidebar: `anchor` (#id) + `background` (select, default Default/Muted/Inverted) + your own fields; instead of a per-block `bgColor`/`sectionId`. | @@ -125,18 +126,19 @@ Fifteen ready blocks and ten page templates. **Use a library block (or a variant | `blockThumbnail(slug)` | `@intecion/ipal-kit/blocks` | Inline SVG sketch (data URL) for the block picker — what `thumbnail: true` uses. | | `faqItemsFromLayout(doc, { field?, slugs? })` | `@intecion/ipal-kit/blocks` | FAQ questions of the page's FAQ blocks → `getPageJsonLd(locale, slug, { faq: faqItemsFromLayout })` (FAQPage). | | `blockLibraryManifest`, `buildBlockLibraryManifest()`, `fieldPaths(fields)` | `@intecion/ipal-kit/blocks` | Plain data: every block's slug, interface name, variants, stored field paths; primitives, field builders, templates — for `ipal-doctor` and tests. | -| `createBlockRegistry(content, options?)` | `@intecion/ipal-kit/blocks/rsc` | `blockType → component` map for `createPageRoute` / `RenderBlocks`, bound to lib/content. Options: `Image`, `Link` (next/image, next/link), `sendForm`, `formClassNames`, `contactDetails`, `classNames` (per block part), `ui` (swap primitives), `components` (swap a block), `backgrounds`, `slugs`, `only`, `extra` (own blocks), `noSnippet` (e.g. `['cta']`), `icons`, `texts`, `lightbox`, `richText`, `entryCard`, `mapTestimonial`. | +| `createBlockRegistry(content, options?)` | `@intecion/ipal-kit/blocks/rsc` | `blockType → component` map for `createPageRoute` / `RenderBlocks`, bound to lib/content. Options: `Image`, `Link` (next/image, next/link), `sendForm`, `formClassNames`, `contactDetails`, `classNames` (per block part), `ui` (swap primitives), `components` (swap a block), `backgrounds`, `slugs`, `only`, `extra` (own blocks), `noSnippet` (e.g. `['cta']`), `itemHeadings`, `priorityImage`, `icons`, `texts`, `lightbox`, `richText`, `entryCard`, `mapTestimonial`. | | `LIBRARY_BLOCK_COMPONENTS` | `@intecion/ipal-kit/blocks/rsc` | The plugin's component per slug. | | `HeroBlock`, `TextMediaBlock`, `FeatureGridBlock`, `GalleryBlock`, `FaqBlock`, `CtaBlock`, `ContactBlock`, `TeamBlock`, `PricingBlock`, `LogosBlock`, `TestimonialsBlock`, `StatsBlock`, `RichTextBlock`, `StepsBlock`, `EntryListBlock` | `@intecion/ipal-kit/blocks/rsc` | The block components (server; props `LibraryBlockProps`: data + `locale`, `isFirst`, `ui`, `ctx`, `classNames`). | | `HERO_PARTS`, `TEXT_MEDIA_PARTS`, `FEATURE_GRID_PARTS`, `GALLERY_PARTS`, `FAQ_PARTS`, `CTA_PARTS`, `CONTACT_PARTS`, `TEAM_PARTS`, `PRICING_PARTS`, `LOGOS_PARTS`, `TESTIMONIALS_PARTS`, `STATS_PARTS`, `RICH_TEXT_PARTS`, `STEPS_PARTS`, `ENTRY_LIST_PARTS` | `@intecion/ipal-kit/blocks/rsc` | Default token classes per block part — the keys of `classNames`. | | `defaultEntryCard(doc)`, `defaultTestimonial(doc)` | `@intecion/ipal-kit/blocks/rsc` | Default mapping of a collection document to an entry card / a testimonial (`entryCard`, `mapTestimonial` replace them). | | `Section`, `SECTION_BACKGROUNDS`, `SectionHeader`, `Media`, `CMSLink`, `Anchor`, `buttonClass`, `BUTTON_CLASSES`, `Container`, `CONTAINER_WIDTHS`, `Card`, `CARD_CLASS`, `CARD_INTERACTIVE_CLASS` | `@intecion/ipal-kit/blocks/rsc` | UI primitives, token utilities only: section (anchor, background, `data-surface`), heading group, image/video, panel link, link element, button looks, page column, card. | +| `itemHeadingLevel(slug, props)`, `leadsWithImage(props)` | `@intecion/ipal-kit/blocks/rsc` | Item heading tag (one below the section heading; `h2` without one; `itemHeadings` overrides) and whether the block's first image is the page's LCP image (`isFirst` / `firstImage`; `priorityImage: false` turns it off). | | `Buttons`, `headingId(block)`, `TitleLink`, `GRID_COLUMNS`, `cx`, `parts(defaults, overrides)` | `@intecion/ipal-kit/blocks/rsc` | Helpers for own blocks: button row, heading id for `aria-labelledby`, card title link (plain text when the link is dead), grid columns, class joining, part classes. | | `BLOCK_TEXTS`, `blockTexts(locale, own?)`, `fillText(text, value)` | `@intecion/ipal-kit/blocks/rsc` | Visitor texts the blocks write (rating, step) in en/pl; override with `texts`. | | `pageTemplates` | `@intecion/ipal-kit/templates` | `home`, `about`, `services`, `service`, `contact`, `blogIndex`, `post`, `legal(role)`, `cookiePolicy`, `notFound` → `{ title, slug, layout }` for `seed.upsertBySlug('pages', …)`. Options: `blocks`, `overrides`, `layout`, `slug`, `title`, `defaultLocale`, `linkTo`; `contact`/`service` take `form` (`{ $form: 'title' }`). After launch: only with `SEED_ONLY`. | | `systemPageRefs(roles)` | `@intecion/ipal-kit/templates` | `{ homepage: 'start' }` → `{ homepage: { $page: 'start' } }` for `seed.fillGlobal('site-settings', …)`. | -**Types:** `BlockOptions`, `BlockBuilder`, `BlockLocalization`, `LibraryBlockSetting`, `LibraryBlocksShared`, `LibraryBlockSlug`, `LibraryBlocksOptions`, `VariantOption`, `LibraryBlockDefinition`, `ContactOptions`, `EntryListOptions`, `FeatureGridOptions`, `TestimonialsOptions`, `ItemsFieldOptions`, `MediaFieldOptions`, `VariantFieldOptions`, `IconFieldOptions`, `Columns`, `BlockLibraryManifest`, `ManifestBlock`, `ManifestField` (`/blocks`); `BlockRegistryOptions`, `BlockContent`, `BlockContext`, `BlockUi`, `LibraryBlockProps`, `ContactDetail`, `EntryCard`, `TestimonialItem`, `BlockTexts`, `PartClasses`, `BaseBlockData`, `LinkData`, `LinksData`, `MediaValue`, `RichTextData`, `SectionHeaderData`, `SectionSettingsData`, `HeroBlockData`, `TextMediaBlockData`, `FeatureGridBlockData`, `FeatureItem`, `GalleryBlockData`, `GalleryItem`, `FaqBlockData`, `FaqItem`, `CtaBlockData`, `ContactBlockData`, `TeamBlockData`, `TeamMember`, `PricingBlockData`, `PricingPlan`, `LogosBlockData`, `LogoItem`, `TestimonialsBlockData`, `StatsBlockData`, `StatItem`, `RichTextBlockData`, `StepsBlockData`, `StepItem`, `EntryListBlockData`, `CMSLinkProps`, `ResolveLink`, `LinkComponent`, `ImageComponent`, `MediaProps`, `SectionProps`, `SectionHeaderProps`, `HeadingLevel`, `CardProps`, `ContainerProps`, `ContainerWidth` (`/blocks/rsc`); `TemplateOptions`, `TemplatePage`, `TemplateBlock`, `TemplateValue` (`/templates`). +**Types:** `BlockOptions`, `BlockBuilder`, `BlockLocalization`, `LibraryBlockSetting`, `LibraryBlocksShared`, `LibraryBlockSlug`, `LibraryBlocksOptions`, `VariantOption`, `LibraryBlockDefinition`, `ContactOptions`, `EntryListOptions`, `FeatureGridOptions`, `TestimonialsOptions`, `ItemsFieldOptions`, `MediaFieldOptions`, `VariantFieldOptions`, `IconFieldOptions`, `Columns`, `BlockLibraryManifest`, `ManifestBlock`, `ManifestField` (`/blocks`); `BlockRegistryOptions`, `BlockContent`, `BlockContext`, `BlockUi`, `LibraryBlockProps`, `ContactDetail`, `EntryCard`, `TestimonialItem`, `BlockTexts`, `PartClasses`, `BaseBlockData`, `LinkData`, `LinksData`, `MediaValue`, `RichTextData`, `SectionHeaderData`, `SectionSettingsData`, `HeroBlockData`, `TextMediaBlockData`, `FeatureGridBlockData`, `FeatureItem`, `GalleryBlockData`, `GalleryItem`, `FaqBlockData`, `FaqItem`, `CtaBlockData`, `ContactBlockData`, `TeamBlockData`, `TeamMember`, `PricingBlockData`, `PricingPlan`, `LogosBlockData`, `LogoItem`, `TestimonialsBlockData`, `StatsBlockData`, `StatItem`, `RichTextBlockData`, `StepsBlockData`, `StepItem`, `EntryListBlockData`, `CMSLinkProps`, `ResolveLink`, `LinkComponent`, `ImageComponent`, `ItemHeadingLevel`, `MediaProps`, `SectionProps`, `SectionHeaderProps`, `HeadingLevel`, `CardProps`, `ContainerProps`, `ContainerWidth` (`/blocks/rsc`); `TemplateOptions`, `TemplatePage`, `TemplateBlock`, `TemplateValue` (`/templates`). ## Cookie consent (`consent`) — details: `node_modules/@intecion/ipal-kit/docs/consent.md` @@ -558,7 +560,7 @@ Server only (`pnpm payload run`); never import it from client code, the Payload | `createSeeder(payload, { dryRun?, update?, force?, only?, guard?, editCheck?, context?, pagesCollection?, formsCollection?, label?, log? })` | `@intecion/ipal-kit/seed` | The seed rules in one place → `{ upsertBySlug, upsertBy, fillGlobal, summary, dryRun, update, force, local, only }`. `only` (or `SEED_ONLY`) = the records the run may touch (`pages:kontakt`, `forms:`, `global:<slug>`, `pages:*`), the rest → `skip (not listed)`; a run without it against production / a non-local database throws unless `IPAL_SEED_ALLOW_FULL=1` / `guard.allowFull: true` (after launch: named records only; dry runs are never refused; `guard: false` turns every guard off). Create-only by default, natural keys, never deletes, globals: empty fields only, every locale with `fallbackLocale: false` onto the same row ids, skips records edited since seeding, writes with `context` `{ ipalSeed, disableRevalidate, ipalSkipIndexNow }`. Throws when `update` runs on production / a non-local database without `IPAL_SEED_ALLOW_PROD_UPDATE=1`. Both seed templates use it. | | `upsertBySlug(collection, data \| data[], { slugField? })` | (method of `createSeeder`) | Matches by the default-locale slug; an array creates missing records first, so `{ $page: 'slug' }` links work in any order; `{ $form: 'title' }` = the form's id (`formsCollection`, default `forms`). | | `upsertBy(collection, key, data)` | (method) | Matches by other keys, e.g. a form by `{ title }`. | -| `fillGlobal(slug, data)` | (method) | Fills only empty fields of a global — a choice (select, radio, checkbox, number, date) still at its `defaultValue` counts as empty, text never does (all seeded fields with `update` when untouched). | +| `fillGlobal(slug, data)` | (method) | Fills only empty fields of a global — a choice (select, radio, checkbox, number, date) still at its `defaultValue` counts as empty, text never does; a field already holding the seeded value is skipped (all seeded fields with `update` when untouched). | | `summary()` | (method) | Prints and returns `{ created, skipped, updated, skippedEdited, errors }`; exit 1 when `errors`. | | `isLocalDatabase(url, { localHosts? })` | `@intecion/ipal-kit/seed` | `true` for SQLite files, Unix sockets, localhost / 127.0.0.1 / ::1 (+ `SEED_LOCAL_HOSTS`). | | `writeLocales(payload, target, data, { context?, draft? })` | `@intecion/ipal-kit/seed` | Writes seed values (`{ pl, en }` per field) to `{ collection, id }` or `{ global }`: default locale first, then every other locale with `fallbackLocale: false` onto the same row ids. | diff --git a/docs/block-library.md b/docs/block-library.md index 587be27..7d18bb2 100644 --- a/docs/block-library.md +++ b/docs/block-library.md @@ -108,8 +108,12 @@ block has them) → `variant` (sidebar) → `settings` (sidebar: anchor, backgro | `entryList` (`buildEntryListBlock`) | Entry list | `entryCollection`, `mode` (latest / chosen), `limit`, `entries` | `cards`, `list` | each title links to its entry and covers the card; dates in `<time>` | **Rules every block meets:** one `<section>` with `aria-labelledby` its heading and `data-ipal-block`; `h1` only in the -first block (`isFirst` from `createPageRoute`), `h2` otherwise, items `h3`; images through `Media` (alt from the media -document, width and height, lazy except the hero); visible focus (`outline-focus`); no autoplay, motion only through +first block (`isFirst` from `createPageRoute`), `h2` otherwise; **item headings one level below the section heading** +(`itemHeadingLevel`: `h3` under a section `h2`, `h2` under the page `h1`, and `h2` when the block shows no heading of its +own — a list right under the page header never jumps from `h1` to `h3`); images through `Media` (alt from the media +document, width and height, lazy) — **except the page's LCP image**: the first image of the block that leads the page +(`leadsWithImage`: the first section, or `firstImage` from `createPageRoute` — no block before it shows an image, e.g. an +entry list under a page header without a picture) loads eagerly with `fetchPriority="high"`, one per block; visible focus (`outline-focus`); no autoplay, motion only through the token durations (0 ms under reduced motion); **an empty block renders nothing** (no empty section, no "Lorem"). **Visitor texts** the components write themselves — `rating` ("Rated {value} out of 5") and `step` ("Step {value}") — @@ -166,6 +170,8 @@ plugin's components. `content` needs `resolveLink`; `getEntries` (entry list), ` | `sendForm`, `formClassNames`, `contactDetails` | the contact block: form action, form classes, details beside the form | | `entryCard`, `mapTestimonial` | how a collection document becomes an entry card / a testimonial (defaults `defaultEntryCard`, `defaultTestimonial`) | | `noSnippet` | blocks kept out of Google's snippets (`<NoSnippet>`), e.g. `['cta']` when the same call to action is on every page (docs/seo.md) | +| `itemHeadings` | item heading level per block, e.g. `{ entryList: 'h3' }` (`h2` / `h3` / `h4`) — default: one below the section heading | +| `priorityImage` | `false` = never mark a block's first image as the LCP image (default on) | | `icons`, `texts`, `lightbox`, `richText` | feature icons by name; visitor texts; `lightbox: false` = plain gallery images; `richText.className` for every rich text | **UI primitives** (`/blocks/rsc`), each styled once with token utilities: `Section` (anchor, background, @@ -176,7 +182,8 @@ keeps its content without a link, so an empty link group never hides it), `buttonClass` / `BUTTON_CLASSES` (button looks by appearance), `Container` / `CONTAINER_WIDTHS`, `Card` / `CARD_CLASS` / `CARD_INTERACTIVE_CLASS`. Helpers for the project's own blocks: `Buttons` (a block's button row), `headingId(block)` (the heading id for `aria-labelledby`), `TitleLink` (a card title that links when its link resolves), `GRID_COLUMNS`, -`cx`, `parts(defaults, overrides)`. +`cx`, `parts(defaults, overrides)`, `itemHeadingLevel(slug, props)` (the item heading tag) and `leadsWithImage(props)` +(whether the block's first image is the LCP image). **Every component is exported** (`HeroBlock`, `TextMediaBlock`, `FeatureGridBlock`, `GalleryBlock`, `FaqBlock`, `CtaBlock`, `ContactBlock`, `TeamBlock`, `PricingBlock`, `LogosBlock`, `TestimonialsBlock`, `StatsBlock`, `RichTextBlock`, diff --git a/docs/blocks.md b/docs/blocks.md index f204cac..1e7cfb8 100644 --- a/docs/blocks.md +++ b/docs/blocks.md @@ -103,7 +103,8 @@ interfaceName })`. The project maps the background values to its `<Section>` cla ## Block component Each component gets the block data as props (plus whatever `enhanceProps` returns; -in `createPageRoute` also `locale`, `isFirst` and `blockProps` — frontend.md). Spacing/layout are yours — the engine does not wrap +in `createPageRoute` also `locale`, `isFirst`, `firstImage` and `blockProps` — frontend.md; `blockPosition` computes the +two for your own `enhanceProps`). Spacing/layout are yours — the engine does not wrap blocks in any markup. ```tsx diff --git a/docs/frontend.md b/docs/frontend.md index b4546f8..841a864 100644 --- a/docs/frontend.md +++ b/docs/frontend.md @@ -111,7 +111,10 @@ export const generateStaticParams = route.generateStaticParams Order in `Page`: under-construction mode (when `redirect` is passed) → `resolveRoute(locale, segments, 1)` → no route: `resolvePageRedirect` (308) or `onMissing` → home page slug at its own address: 308 to root -(`homeAlias`) → `RenderBlocks` with `{ locale, isFirst, …blockProps }` → `render` (optional) → `<JsonLdGraph>`. +(`homeAlias`) → `RenderBlocks` with `{ locale, isFirst, firstImage, …blockProps }` → `render` (optional) → `<JsonLdGraph>`. +`isFirst` / `firstImage` come from `blockPosition({ allBlocks, index })` (root): the first section (its heading is the +page's `h1`) and "no block before this one shows an image" (its first image is the LCP image; `blockHasImage(data)` +checks a block's data). Your own `enhanceProps` can spread `blockPosition(args)` the same way. | Option | Default | What it does | |---|---|---| diff --git a/docs/seeding.md b/docs/seeding.md index 64684dd..bc4965a 100644 --- a/docs/seeding.md +++ b/docs/seeding.md @@ -203,7 +203,7 @@ is an error for that record, never an empty relation. Ready pages made of librar |---|---| | `upsertBySlug(collection, data \| data[], { slugField })` | matches by the default-locale slug (`slugField`, default `slug`). With an array, missing records are created first (without fields that hold `$page` / `$form` links), then every record gets its full content, so pages can link to each other in any order | | `upsertBy(collection, key, data)` | matches by other natural keys, e.g. `{ title: 'Contact form' }` (all keys must match, default locale) | -| `fillGlobal(slug, data)` | fills only the global's empty fields (the default locale decides). A choice — select, radio, checkbox, number, date — still at the field's `defaultValue` counts as empty (Payload stores defaults on the first save, so `defaultTheme: 'system'` can be seeded over `light`); text is never treated so, even when it equals a default. With `update` and an untouched global: every seeded field | +| `fillGlobal(slug, data)` | fills only the global's empty fields (the default locale decides). A choice — select, radio, checkbox, number, date — still at the field's `defaultValue` counts as empty (Payload stores defaults on the first save, so `defaultTheme: 'system'` can be seeded over `light`); text is never treated so, even when it equals a default. A field that already holds exactly the seeded value is not written (`skip (exists)`), so re-running a seed of defaults changes nothing. With `update` and an untouched global: every seeded field | | `summary()` | prints the summary and returns `{ created, skipped, updated, skippedEdited, errors }` | Each method prints one line per record (see [Running a seed](#running-a-seed)) and returns diff --git a/reference/.agents/skills/ipal-reference/resources/api.md b/reference/.agents/skills/ipal-reference/resources/api.md index 4ec4ddc..c789cd2 100644 --- a/reference/.agents/skills/ipal-reference/resources/api.md +++ b/reference/.agents/skills/ipal-reference/resources/api.md @@ -104,6 +104,7 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT | Export | Import from | What it does / when | |---|---|---| | `RenderBlocks` | `@intecion/ipal-kit/rsc` | Server block renderer: `{ blocks, components, enhanceProps? }` — each block through a `blockType → component` map, skips unknown ones, no extra markup. Do not write your own loop over blocks. Nested blocks render their own `RenderBlocks` (do not pass the map as a prop). | +| `blockPosition({ allBlocks, index })`, `blockHasImage(data)` | `@intecion/ipal-kit` | `{ isFirst, firstImage }` for a block — first section (page `h1`) and "no earlier block shows an image" (LCP image); createPageRoute passes both, spread it in your own `enhanceProps`. | | `buildSectionHeaderField(opts?)` | `@intecion/ipal-kit` | `header` field group (eyebrow, heading, intro — localized) for every section block; `interfaceName` `SectionHeaderData`. Options: `name`, `fields`, `interfaceName`. | | `buildSectionSettingsField(opts?)` | `@intecion/ipal-kit` | `settings` group in the block sidebar: `anchor` (#id) + `background` (select, default Default/Muted/Inverted) + your own fields; instead of a per-block `bgColor`/`sectionId`. | @@ -125,18 +126,19 @@ Fifteen ready blocks and ten page templates. **Use a library block (or a variant | `blockThumbnail(slug)` | `@intecion/ipal-kit/blocks` | Inline SVG sketch (data URL) for the block picker — what `thumbnail: true` uses. | | `faqItemsFromLayout(doc, { field?, slugs? })` | `@intecion/ipal-kit/blocks` | FAQ questions of the page's FAQ blocks → `getPageJsonLd(locale, slug, { faq: faqItemsFromLayout })` (FAQPage). | | `blockLibraryManifest`, `buildBlockLibraryManifest()`, `fieldPaths(fields)` | `@intecion/ipal-kit/blocks` | Plain data: every block's slug, interface name, variants, stored field paths; primitives, field builders, templates — for `ipal-doctor` and tests. | -| `createBlockRegistry(content, options?)` | `@intecion/ipal-kit/blocks/rsc` | `blockType → component` map for `createPageRoute` / `RenderBlocks`, bound to lib/content. Options: `Image`, `Link` (next/image, next/link), `sendForm`, `formClassNames`, `contactDetails`, `classNames` (per block part), `ui` (swap primitives), `components` (swap a block), `backgrounds`, `slugs`, `only`, `extra` (own blocks), `noSnippet` (e.g. `['cta']`), `icons`, `texts`, `lightbox`, `richText`, `entryCard`, `mapTestimonial`. | +| `createBlockRegistry(content, options?)` | `@intecion/ipal-kit/blocks/rsc` | `blockType → component` map for `createPageRoute` / `RenderBlocks`, bound to lib/content. Options: `Image`, `Link` (next/image, next/link), `sendForm`, `formClassNames`, `contactDetails`, `classNames` (per block part), `ui` (swap primitives), `components` (swap a block), `backgrounds`, `slugs`, `only`, `extra` (own blocks), `noSnippet` (e.g. `['cta']`), `itemHeadings`, `priorityImage`, `icons`, `texts`, `lightbox`, `richText`, `entryCard`, `mapTestimonial`. | | `LIBRARY_BLOCK_COMPONENTS` | `@intecion/ipal-kit/blocks/rsc` | The plugin's component per slug. | | `HeroBlock`, `TextMediaBlock`, `FeatureGridBlock`, `GalleryBlock`, `FaqBlock`, `CtaBlock`, `ContactBlock`, `TeamBlock`, `PricingBlock`, `LogosBlock`, `TestimonialsBlock`, `StatsBlock`, `RichTextBlock`, `StepsBlock`, `EntryListBlock` | `@intecion/ipal-kit/blocks/rsc` | The block components (server; props `LibraryBlockProps`: data + `locale`, `isFirst`, `ui`, `ctx`, `classNames`). | | `HERO_PARTS`, `TEXT_MEDIA_PARTS`, `FEATURE_GRID_PARTS`, `GALLERY_PARTS`, `FAQ_PARTS`, `CTA_PARTS`, `CONTACT_PARTS`, `TEAM_PARTS`, `PRICING_PARTS`, `LOGOS_PARTS`, `TESTIMONIALS_PARTS`, `STATS_PARTS`, `RICH_TEXT_PARTS`, `STEPS_PARTS`, `ENTRY_LIST_PARTS` | `@intecion/ipal-kit/blocks/rsc` | Default token classes per block part — the keys of `classNames`. | | `defaultEntryCard(doc)`, `defaultTestimonial(doc)` | `@intecion/ipal-kit/blocks/rsc` | Default mapping of a collection document to an entry card / a testimonial (`entryCard`, `mapTestimonial` replace them). | | `Section`, `SECTION_BACKGROUNDS`, `SectionHeader`, `Media`, `CMSLink`, `Anchor`, `buttonClass`, `BUTTON_CLASSES`, `Container`, `CONTAINER_WIDTHS`, `Card`, `CARD_CLASS`, `CARD_INTERACTIVE_CLASS` | `@intecion/ipal-kit/blocks/rsc` | UI primitives, token utilities only: section (anchor, background, `data-surface`), heading group, image/video, panel link, link element, button looks, page column, card. | +| `itemHeadingLevel(slug, props)`, `leadsWithImage(props)` | `@intecion/ipal-kit/blocks/rsc` | Item heading tag (one below the section heading; `h2` without one; `itemHeadings` overrides) and whether the block's first image is the page's LCP image (`isFirst` / `firstImage`; `priorityImage: false` turns it off). | | `Buttons`, `headingId(block)`, `TitleLink`, `GRID_COLUMNS`, `cx`, `parts(defaults, overrides)` | `@intecion/ipal-kit/blocks/rsc` | Helpers for own blocks: button row, heading id for `aria-labelledby`, card title link (plain text when the link is dead), grid columns, class joining, part classes. | | `BLOCK_TEXTS`, `blockTexts(locale, own?)`, `fillText(text, value)` | `@intecion/ipal-kit/blocks/rsc` | Visitor texts the blocks write (rating, step) in en/pl; override with `texts`. | | `pageTemplates` | `@intecion/ipal-kit/templates` | `home`, `about`, `services`, `service`, `contact`, `blogIndex`, `post`, `legal(role)`, `cookiePolicy`, `notFound` → `{ title, slug, layout }` for `seed.upsertBySlug('pages', …)`. Options: `blocks`, `overrides`, `layout`, `slug`, `title`, `defaultLocale`, `linkTo`; `contact`/`service` take `form` (`{ $form: 'title' }`). After launch: only with `SEED_ONLY`. | | `systemPageRefs(roles)` | `@intecion/ipal-kit/templates` | `{ homepage: 'start' }` → `{ homepage: { $page: 'start' } }` for `seed.fillGlobal('site-settings', …)`. | -**Types:** `BlockOptions`, `BlockBuilder`, `BlockLocalization`, `LibraryBlockSetting`, `LibraryBlocksShared`, `LibraryBlockSlug`, `LibraryBlocksOptions`, `VariantOption`, `LibraryBlockDefinition`, `ContactOptions`, `EntryListOptions`, `FeatureGridOptions`, `TestimonialsOptions`, `ItemsFieldOptions`, `MediaFieldOptions`, `VariantFieldOptions`, `IconFieldOptions`, `Columns`, `BlockLibraryManifest`, `ManifestBlock`, `ManifestField` (`/blocks`); `BlockRegistryOptions`, `BlockContent`, `BlockContext`, `BlockUi`, `LibraryBlockProps`, `ContactDetail`, `EntryCard`, `TestimonialItem`, `BlockTexts`, `PartClasses`, `BaseBlockData`, `LinkData`, `LinksData`, `MediaValue`, `RichTextData`, `SectionHeaderData`, `SectionSettingsData`, `HeroBlockData`, `TextMediaBlockData`, `FeatureGridBlockData`, `FeatureItem`, `GalleryBlockData`, `GalleryItem`, `FaqBlockData`, `FaqItem`, `CtaBlockData`, `ContactBlockData`, `TeamBlockData`, `TeamMember`, `PricingBlockData`, `PricingPlan`, `LogosBlockData`, `LogoItem`, `TestimonialsBlockData`, `StatsBlockData`, `StatItem`, `RichTextBlockData`, `StepsBlockData`, `StepItem`, `EntryListBlockData`, `CMSLinkProps`, `ResolveLink`, `LinkComponent`, `ImageComponent`, `MediaProps`, `SectionProps`, `SectionHeaderProps`, `HeadingLevel`, `CardProps`, `ContainerProps`, `ContainerWidth` (`/blocks/rsc`); `TemplateOptions`, `TemplatePage`, `TemplateBlock`, `TemplateValue` (`/templates`). +**Types:** `BlockOptions`, `BlockBuilder`, `BlockLocalization`, `LibraryBlockSetting`, `LibraryBlocksShared`, `LibraryBlockSlug`, `LibraryBlocksOptions`, `VariantOption`, `LibraryBlockDefinition`, `ContactOptions`, `EntryListOptions`, `FeatureGridOptions`, `TestimonialsOptions`, `ItemsFieldOptions`, `MediaFieldOptions`, `VariantFieldOptions`, `IconFieldOptions`, `Columns`, `BlockLibraryManifest`, `ManifestBlock`, `ManifestField` (`/blocks`); `BlockRegistryOptions`, `BlockContent`, `BlockContext`, `BlockUi`, `LibraryBlockProps`, `ContactDetail`, `EntryCard`, `TestimonialItem`, `BlockTexts`, `PartClasses`, `BaseBlockData`, `LinkData`, `LinksData`, `MediaValue`, `RichTextData`, `SectionHeaderData`, `SectionSettingsData`, `HeroBlockData`, `TextMediaBlockData`, `FeatureGridBlockData`, `FeatureItem`, `GalleryBlockData`, `GalleryItem`, `FaqBlockData`, `FaqItem`, `CtaBlockData`, `ContactBlockData`, `TeamBlockData`, `TeamMember`, `PricingBlockData`, `PricingPlan`, `LogosBlockData`, `LogoItem`, `TestimonialsBlockData`, `StatsBlockData`, `StatItem`, `RichTextBlockData`, `StepsBlockData`, `StepItem`, `EntryListBlockData`, `CMSLinkProps`, `ResolveLink`, `LinkComponent`, `ImageComponent`, `ItemHeadingLevel`, `MediaProps`, `SectionProps`, `SectionHeaderProps`, `HeadingLevel`, `CardProps`, `ContainerProps`, `ContainerWidth` (`/blocks/rsc`); `TemplateOptions`, `TemplatePage`, `TemplateBlock`, `TemplateValue` (`/templates`). ## Cookie consent (`consent`) — details: `node_modules/@intecion/ipal-kit/docs/consent.md` @@ -558,7 +560,7 @@ Server only (`pnpm payload run`); never import it from client code, the Payload | `createSeeder(payload, { dryRun?, update?, force?, only?, guard?, editCheck?, context?, pagesCollection?, formsCollection?, label?, log? })` | `@intecion/ipal-kit/seed` | The seed rules in one place → `{ upsertBySlug, upsertBy, fillGlobal, summary, dryRun, update, force, local, only }`. `only` (or `SEED_ONLY`) = the records the run may touch (`pages:kontakt`, `forms:<title>`, `global:<slug>`, `pages:*`), the rest → `skip (not listed)`; a run without it against production / a non-local database throws unless `IPAL_SEED_ALLOW_FULL=1` / `guard.allowFull: true` (after launch: named records only; dry runs are never refused; `guard: false` turns every guard off). Create-only by default, natural keys, never deletes, globals: empty fields only, every locale with `fallbackLocale: false` onto the same row ids, skips records edited since seeding, writes with `context` `{ ipalSeed, disableRevalidate, ipalSkipIndexNow }`. Throws when `update` runs on production / a non-local database without `IPAL_SEED_ALLOW_PROD_UPDATE=1`. Both seed templates use it. | | `upsertBySlug(collection, data \| data[], { slugField? })` | (method of `createSeeder`) | Matches by the default-locale slug; an array creates missing records first, so `{ $page: 'slug' }` links work in any order; `{ $form: 'title' }` = the form's id (`formsCollection`, default `forms`). | | `upsertBy(collection, key, data)` | (method) | Matches by other keys, e.g. a form by `{ title }`. | -| `fillGlobal(slug, data)` | (method) | Fills only empty fields of a global — a choice (select, radio, checkbox, number, date) still at its `defaultValue` counts as empty, text never does (all seeded fields with `update` when untouched). | +| `fillGlobal(slug, data)` | (method) | Fills only empty fields of a global — a choice (select, radio, checkbox, number, date) still at its `defaultValue` counts as empty, text never does; a field already holding the seeded value is skipped (all seeded fields with `update` when untouched). | | `summary()` | (method) | Prints and returns `{ created, skipped, updated, skippedEdited, errors }`; exit 1 when `errors`. | | `isLocalDatabase(url, { localHosts? })` | `@intecion/ipal-kit/seed` | `true` for SQLite files, Unix sockets, localhost / 127.0.0.1 / ::1 (+ `SEED_LOCAL_HOSTS`). | | `writeLocales(payload, target, data, { context?, draft? })` | `@intecion/ipal-kit/seed` | Writes seed values (`{ pl, en }` per field) to `{ collection, id }` or `{ global }`: default locale first, then every other locale with `fallbackLocale: false` onto the same row ids. | diff --git a/reference/ipal-doctor.json b/reference/ipal-doctor.json index aaf5149..d1b8bb1 100644 --- a/reference/ipal-doctor.json +++ b/reference/ipal-doctor.json @@ -18,16 +18,6 @@ "until": "2026-11-30", "reason": "Follow-up for the reference-site track: three pages per language have no own meta description and fall back to the site description; the seed should give each page one" }, - "live-seo:heading-levels-skipped": { - "off": true, - "until": "2026-11-30", - "reason": "Follow-up for the block-library track: entryList cards use h3 with no h2 on the archive pages (h1 → h3)" - }, - "live-seo:first-image-not-prioritised-lcp": { - "off": true, - "until": "2026-11-30", - "reason": "Follow-up for the block-library track: on the archive pages the first image is an entryList card, which is not marked priority" - }, "live-seo:thin-pages-words": { "off": true, "until": "2026-11-30", diff --git a/src/exports/blocks-rsc.ts b/src/exports/blocks-rsc.ts index 175fae3..47f25a2 100644 --- a/src/exports/blocks-rsc.ts +++ b/src/exports/blocks-rsc.ts @@ -54,6 +54,8 @@ export { Container, CONTAINER_WIDTHS } from '../modules/block-library/ui/Contain export type { ContainerProps, ContainerWidth } from '../modules/block-library/ui/Container.js' export { cx, parts } from '../modules/block-library/ui/cx.js' export type { PartClasses } from '../modules/block-library/ui/cx.js' +export { itemHeadingLevel, leadsWithImage } from '../modules/block-library/ui/levels.js' +export type { ItemHeadingLevel } from '../modules/block-library/ui/levels.js' export { Media } from '../modules/block-library/ui/Media.js' export type { ImageComponent, MediaProps } from '../modules/block-library/ui/Media.js' export { Section, SECTION_BACKGROUNDS } from '../modules/block-library/ui/Section.js' diff --git a/src/index.ts b/src/index.ts index 2c1177e..e4e022c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,6 +32,7 @@ export type { AnalyticsConfig } from './modules/analytics/index.js' export { getAnalyticsConfig } from './modules/analytics/index.js' export { shouldLoadGoogle } from './modules/analytics/shouldLoadGoogle.js' // Shared section fields (header: eyebrow/heading/intro, settings: anchor/background). +export { blockHasImage, blockPosition } from './modules/blocks/position.js' export { buildSectionHeaderField, buildSectionSettingsField } from './modules/blocks/sectionFields.js' export type { SectionHeaderFieldOptions, SectionSettingsFieldOptions } from './modules/blocks/sectionFields.js' export { buildAdminImageEndpoints } from './modules/branding/adminImages.js' diff --git a/src/modules/block-library/blocks/entryList/Component.tsx b/src/modules/block-library/blocks/entryList/Component.tsx index 6c6243d..940b844 100644 --- a/src/modules/block-library/blocks/entryList/Component.tsx +++ b/src/modules/block-library/blocks/entryList/Component.tsx @@ -4,6 +4,7 @@ import type { BaseBlockData } from '../../data.js' import { MEDIA_SIZES } from '../../../media/mediaProps.js' import { Buttons, headingId } from '../../ui/Buttons.js' import { cx, parts } from '../../ui/cx.js' +import { itemHeadingLevel, leadsWithImage } from '../../ui/levels.js' import { TitleLink } from '../../ui/TitleLink.js' export type EntryListBlockData = { @@ -53,6 +54,8 @@ export async function EntryListBlock(props: LibraryBlockProps<EntryListBlockData const c = parts(ENTRY_LIST_PARTS, classNames) const id = headingId(props) const dates = new Intl.DateTimeFormat(locale, { dateStyle: 'long' }) + const H = itemHeadingLevel('entryList', props) + const lead = leadsWithImage(props) return ( <ui.Section block={props.blockType} labelledBy={id} settings={settings}> <ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} /> @@ -60,14 +63,14 @@ export async function EntryListBlock(props: LibraryBlockProps<EntryListBlockData {rows.map(({ card, collection: from, doc }, i) => ( <li className="flex" key={typeof doc.id === 'string' || typeof doc.id === 'number' ? doc.id : i}> <ui.Card className={cx('w-full', c.card)} interactive> - {variant === 'list' ? null : <ui.Media className={c.media} resource={card.media as never} sizes={MEDIA_SIZES.third} />} + {variant === 'list' ? null : <ui.Media className={c.media} priority={lead && i === 0} resource={card.media as never} sizes={MEDIA_SIZES.third} />} <div className="flex flex-col gap-2 p-6 pt-0 first:pt-6"> {card.date ? <time className={c.date} dateTime={card.date}>{dates.format(new Date(card.date))}</time> : null} - <h3 className={c.title}> + <H className={c.title}> <TitleLink link={{ type: 'internal', page: { relationTo: from, value: doc } }} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink}> {card.title} </TitleLink> - </h3> + </H> {card.text ? <p className={c.text}>{card.text}</p> : null} </div> </ui.Card> diff --git a/src/modules/block-library/blocks/featureGrid/Component.tsx b/src/modules/block-library/blocks/featureGrid/Component.tsx index cc1f54c..4af24e2 100644 --- a/src/modules/block-library/blocks/featureGrid/Component.tsx +++ b/src/modules/block-library/blocks/featureGrid/Component.tsx @@ -1,9 +1,11 @@ import type { BlockContext, BlockUi, LibraryBlockProps } from '../../context.js' import type { BaseBlockData, LinkData, MediaValue } from '../../data.js' +import type { ItemHeadingLevel } from '../../ui/levels.js' import { MEDIA_SIZES } from '../../../media/mediaProps.js' import { Buttons, GRID_COLUMNS, headingId } from '../../ui/Buttons.js' import { cx, parts } from '../../ui/cx.js' +import { itemHeadingLevel, leadsWithImage } from '../../ui/levels.js' import { TitleLink } from '../../ui/TitleLink.js' export type FeatureItem = { heading: string; icon?: null | string; id?: null | string; link?: LinkData; media?: MediaValue; text?: null | string } @@ -28,13 +30,15 @@ export function FeatureGridBlock(props: LibraryBlockProps<FeatureGridBlockData>) const id = headingId(props) const v = variant ?? 'cards' const List = v === 'numbered' ? 'ol' : 'ul' + const H = itemHeadingLevel('featureGrid', props) + const lead = leadsWithImage(props) return ( <ui.Section block={props.blockType} labelledBy={id} settings={settings}> <ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} /> <List className={cx(v === 'list' ? c.list : c.grid, GRID_COLUMNS[columns ?? 'three'])}> {items.map((item, i) => ( <li className="flex" key={item.id ?? i}> - <FeatureCard c={c} ctx={ctx} index={v === 'numbered' ? i + 1 : undefined} item={item} locale={locale} plain={v === 'list'} ui={ui} /> + <FeatureCard as={H} c={c} ctx={ctx} index={v === 'numbered' ? i + 1 : undefined} item={item} locale={locale} plain={v === 'list'} priority={lead && i === 0} ui={ui} /> </li> ))} </List> @@ -43,7 +47,7 @@ export function FeatureGridBlock(props: LibraryBlockProps<FeatureGridBlockData>) ) } -function FeatureCard({ c, ctx, index, item, locale, plain, ui }: { c: typeof FEATURE_GRID_PARTS; ctx: BlockContext; index?: number; item: FeatureItem; locale: string; plain: boolean; ui: BlockUi }) { +function FeatureCard({ as: H, c, ctx, index, item, locale, plain, priority, ui }: { as: ItemHeadingLevel; c: typeof FEATURE_GRID_PARTS; ctx: BlockContext; index?: number; item: FeatureItem; locale: string; plain: boolean; priority: boolean; ui: BlockUi }) { const Icon = item.icon ? ctx.icons?.[item.icon] : undefined const heading = item.link ? ( <TitleLink link={item.link} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink}> @@ -56,8 +60,8 @@ function FeatureCard({ c, ctx, index, item, locale, plain, ui }: { c: typeof FEA <> {index ? <span aria-hidden className={c.number}>{String(index).padStart(2, '0')}</span> : null} {Icon ? <Icon aria-hidden className={c.icon} /> : null} - <ui.Media className={c.media} resource={item.media} sizes={MEDIA_SIZES.third} /> - <h3 className={c.heading}>{heading}</h3> + <ui.Media className={c.media} priority={priority} resource={item.media} sizes={MEDIA_SIZES.third} /> + <H className={c.heading}>{heading}</H> {item.text ? <p className={c.text}>{item.text}</p> : null} </> ) diff --git a/src/modules/block-library/blocks/gallery/Component.tsx b/src/modules/block-library/blocks/gallery/Component.tsx index b19718c..8cbb2bf 100644 --- a/src/modules/block-library/blocks/gallery/Component.tsx +++ b/src/modules/block-library/blocks/gallery/Component.tsx @@ -6,6 +6,7 @@ import { LightboxTrigger } from '../../../lightbox/LightboxProvider.js' import { MEDIA_SIZES } from '../../../media/mediaProps.js' import { Buttons, GRID_COLUMNS, headingId } from '../../ui/Buttons.js' import { cx, parts } from '../../ui/cx.js' +import { leadsWithImage } from '../../ui/levels.js' export type GalleryItem = { caption?: null | string; id?: null | string; media?: MediaValue } export type GalleryBlockData = { columns?: null | string; items?: GalleryItem[] | null } & BaseBlockData @@ -28,13 +29,14 @@ export function GalleryBlock(props: LibraryBlockProps<GalleryBlockData>) { const id = headingId(props) const group = `gallery-${props.id ?? 'block'}` const masonry = variant === 'masonry' + const lead = leadsWithImage(props) const sizes = columns === 'two' ? MEDIA_SIZES.half : columns === 'four' ? MEDIA_SIZES.quarter : MEDIA_SIZES.third return ( <ui.Section block={props.blockType} labelledBy={id} settings={settings} width="wide"> <ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} /> <ul className={masonry ? c.masonry : cx(c.grid, GRID_COLUMNS[columns ?? 'three'])}> {shown.map((item, i) => { - const image = <ui.Media className={c.image} resource={item.media} sizes={sizes} /> + const image = <ui.Media className={c.image} priority={lead && i === 0} resource={item.media} sizes={sizes} /> const large = ctx.lightbox ? lightboxImage(item.media, item.caption ? { caption: item.caption } : {}) : null return ( <li key={item.id ?? i}> diff --git a/src/modules/block-library/blocks/hero/Component.tsx b/src/modules/block-library/blocks/hero/Component.tsx index 1bd7d27..9f0efa4 100644 --- a/src/modules/block-library/blocks/hero/Component.tsx +++ b/src/modules/block-library/blocks/hero/Component.tsx @@ -4,6 +4,7 @@ import type { BaseBlockData, MediaValue } from '../../data.js' import { MEDIA_SIZES } from '../../../media/mediaProps.js' import { Buttons, headingId } from '../../ui/Buttons.js' import { cx, parts } from '../../ui/cx.js' +import { leadsWithImage } from '../../ui/levels.js' export type HeroBlockData = { media?: MediaValue; poster?: MediaValue } & BaseBlockData @@ -30,7 +31,7 @@ export function HeroBlock(props: LibraryBlockProps<HeroBlockData>) { if (v === 'background') { return ( <ui.Section block={props.blockType} className={c.background} labelledBy={id} settings={{ ...settings, background: 'inverted' }}> - <ui.Media alt="" className={c.backgroundMedia} poster={poster} priority={isFirst} resource={media} sizes={MEDIA_SIZES.full} videoMode="background" /> + <ui.Media alt="" className={c.backgroundMedia} poster={poster} priority={leadsWithImage({ ctx: props.ctx, firstImage: props.firstImage, isFirst })} resource={media} sizes={MEDIA_SIZES.full} videoMode="background" /> <span aria-hidden className={c.backgroundOverlay} /> <div className={c.page}> {title} @@ -47,7 +48,7 @@ export function HeroBlock(props: LibraryBlockProps<HeroBlockData>) { {title} {buttons} </div> - {withMedia ? <ui.Media className={c.media} poster={poster} priority={isFirst} resource={media} sizes={MEDIA_SIZES.half} /> : null} + {withMedia ? <ui.Media className={c.media} poster={poster} priority={leadsWithImage({ ctx: props.ctx, firstImage: props.firstImage, isFirst })} resource={media} sizes={MEDIA_SIZES.half} /> : null} </div> </ui.Section> ) diff --git a/src/modules/block-library/blocks/pricing/Component.tsx b/src/modules/block-library/blocks/pricing/Component.tsx index 875008d..8ffeed4 100644 --- a/src/modules/block-library/blocks/pricing/Component.tsx +++ b/src/modules/block-library/blocks/pricing/Component.tsx @@ -1,8 +1,10 @@ import type { BlockUi, LibraryBlockProps } from '../../context.js' import type { BaseBlockData, LinkData } from '../../data.js' +import type { ItemHeadingLevel } from '../../ui/levels.js' import { headingId } from '../../ui/Buttons.js' import { cx, parts } from '../../ui/cx.js' +import { itemHeadingLevel } from '../../ui/levels.js' export type PricingPlan = { features?: { id?: null | string; text: string }[] | null @@ -35,13 +37,14 @@ export function PricingBlock(props: LibraryBlockProps<PricingBlockData>) { if (!items?.length) {return null} const c = parts(PRICING_PARTS, classNames) const id = headingId(props) + const H = itemHeadingLevel('pricing', props) return ( <ui.Section block={props.blockType} labelledBy={id} settings={settings}> <ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} /> <ul className={c.grid}> {items.map((plan, i) => ( <li className="flex" key={plan.id ?? i}> - <Plan c={c} highlightLabel={highlightLabel} locale={locale} plan={plan} ui={ui} /> + <Plan as={H} c={c} highlightLabel={highlightLabel} locale={locale} plan={plan} ui={ui} /> </li> ))} </ul> @@ -50,11 +53,11 @@ export function PricingBlock(props: LibraryBlockProps<PricingBlockData>) { ) } -function Plan({ c, highlightLabel, locale, plan, ui }: { c: typeof PRICING_PARTS; highlightLabel?: null | string; locale: string; plan: PricingPlan; ui: BlockUi }) { +function Plan({ as: H, c, highlightLabel, locale, plan, ui }: { as: ItemHeadingLevel; c: typeof PRICING_PARTS; highlightLabel?: null | string; locale: string; plan: PricingPlan; ui: BlockUi }) { return ( <ui.Card className={cx('w-full', c.plan, plan.highlighted && c.highlighted)}> {plan.highlighted && highlightLabel ? <p className={c.badge}>{highlightLabel}</p> : null} - <h3 className={c.name}>{plan.heading}</h3> + <H className={c.name}>{plan.heading}</H> <p> <span className={c.price}>{plan.price}</span> {plan.period ? <span className={c.period}>{plan.period}</span> : null} </p> diff --git a/src/modules/block-library/blocks/steps/Component.tsx b/src/modules/block-library/blocks/steps/Component.tsx index 3a3c54f..7d25787 100644 --- a/src/modules/block-library/blocks/steps/Component.tsx +++ b/src/modules/block-library/blocks/steps/Component.tsx @@ -5,6 +5,7 @@ import { MEDIA_SIZES } from '../../../media/mediaProps.js' import { blockTexts, fillText } from '../../texts.js' import { Buttons, headingId } from '../../ui/Buttons.js' import { cx, parts } from '../../ui/cx.js' +import { itemHeadingLevel } from '../../ui/levels.js' export type StepItem = { heading: string; id?: null | string; media?: MediaValue; text?: null | string } export type StepsBlockData = { items?: null | StepItem[] } & BaseBlockData @@ -26,6 +27,7 @@ export function StepsBlock(props: LibraryBlockProps<StepsBlockData>) { const c = parts(STEPS_PARTS, classNames) const texts = blockTexts(locale, ctx.texts) const id = headingId(props) + const H = itemHeadingLevel('steps', props) return ( <ui.Section block={props.blockType} labelledBy={id} settings={settings}> <ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} /> @@ -34,10 +36,10 @@ export function StepsBlock(props: LibraryBlockProps<StepsBlockData>) { <li className={c.item} key={s.id ?? i}> <span aria-hidden className={cx(c.number, 'relative')}>{i + 1}</span> <div> - <h3 className={c.heading}> + <H className={c.heading}> <span className="sr-only">{fillText(texts.step, i + 1)}: </span> {s.heading} - </h3> + </H> {s.text ? <p className={c.text}>{s.text}</p> : null} <ui.Media className={c.media} resource={s.media} sizes={MEDIA_SIZES.half} /> </div> diff --git a/src/modules/block-library/blocks/team/Component.tsx b/src/modules/block-library/blocks/team/Component.tsx index 82c29e4..9cb916d 100644 --- a/src/modules/block-library/blocks/team/Component.tsx +++ b/src/modules/block-library/blocks/team/Component.tsx @@ -4,6 +4,7 @@ import type { BaseBlockData, LinkData, MediaValue } from '../../data.js' import { MEDIA_SIZES } from '../../../media/mediaProps.js' import { Buttons, headingId } from '../../ui/Buttons.js' import { cx, parts } from '../../ui/cx.js' +import { itemHeadingLevel, leadsWithImage } from '../../ui/levels.js' import { TitleLink } from '../../ui/TitleLink.js' export type TeamMember = { bio?: null | string; heading: string; id?: null | string; link?: LinkData; media?: MediaValue; text?: null | string } @@ -26,17 +27,19 @@ export function TeamBlock(props: LibraryBlockProps<TeamBlockData>) { const c = parts(TEAM_PARTS, classNames) const id = headingId(props) const list = variant === 'list' + const H = itemHeadingLevel('team', props) + const lead = leadsWithImage(props) return ( <ui.Section block={props.blockType} labelledBy={id} settings={settings}> <ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} /> <ul className={list ? c.list : c.grid}> {items.map((m, i) => ( <li className={cx('flex flex-col gap-3', list && c.listItem)} key={m.id ?? i}> - <ui.Media className={c.photo} resource={m.media} sizes={list ? '10rem' : MEDIA_SIZES.third} /> + <ui.Media className={c.photo} priority={lead && i === 0} resource={m.media} sizes={list ? '10rem' : MEDIA_SIZES.third} /> <div className="flex flex-col gap-1"> - <h3 className={c.name}><TitleLink link={m.link} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink} stretch={false}> + <H className={c.name}><TitleLink link={m.link} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink} stretch={false}> {m.heading} - </TitleLink></h3> + </TitleLink></H> {m.text ? <p className={c.role}>{m.text}</p> : null} {m.bio ? <p className={c.bio}>{m.bio}</p> : null} </div> diff --git a/src/modules/block-library/blocks/textMedia/Component.tsx b/src/modules/block-library/blocks/textMedia/Component.tsx index 8c897ce..e7136c8 100644 --- a/src/modules/block-library/blocks/textMedia/Component.tsx +++ b/src/modules/block-library/blocks/textMedia/Component.tsx @@ -5,6 +5,7 @@ import { MEDIA_SIZES } from '../../../media/mediaProps.js' import { RenderRichText } from '../../../richtext/RenderRichText.js' import { Buttons, headingId } from '../../ui/Buttons.js' import { cx, parts } from '../../ui/cx.js' +import { leadsWithImage } from '../../ui/levels.js' export type TextMediaBlockData = { content?: RichTextData; media?: MediaValue } & BaseBlockData @@ -30,7 +31,7 @@ export function TextMediaBlock(props: LibraryBlockProps<TextMediaBlockData>) { </div> {media ? ( <div className={variant === 'mediaLeft' ? c.mediaLeft : undefined}> - <ui.Media className={c.media} priority={isFirst} resource={media} sizes={MEDIA_SIZES.half} /> + <ui.Media className={c.media} priority={leadsWithImage(props)} resource={media} sizes={MEDIA_SIZES.half} /> </div> ) : null} </div> diff --git a/src/modules/block-library/context.ts b/src/modules/block-library/context.ts index 418dece..b00518d 100644 --- a/src/modules/block-library/context.ts +++ b/src/modules/block-library/context.ts @@ -5,6 +5,7 @@ import type { BuilderFormClassNames } from '../forms/BuilderForm.js' import type { SendFormAction } from '../forms/RenderForm.js' import type { ResolveLinkHrefOptions } from '../links/resolveLinkHref.js' import type { BlockTexts } from './texts.js' +import type { LibraryBlockSlug } from './types.js' import type { LinkComponent } from './ui/Anchor.js' import type { CardProps } from './ui/Card.js' import type { CMSLinkProps, ResolveLink } from './ui/CMSLink.js' @@ -54,12 +55,16 @@ export type BlockContext = { icons?: Record<string, ComponentType<{ 'aria-hidden'?: boolean; className?: string }>> /** next/image — optimized images with blur-up. Without it: a plain <img>. */ Image?: ImageComponent + /** Heading level of a block's items (cards, plans, steps), per block. Default: one below the section heading (itemHeadingLevel). */ + itemHeadings?: Partial<Record<LibraryBlockSlug, 'h2' | 'h3' | 'h4'>> /** Lightbox triggers on gallery images. Default true (needs <SiteProviders lightbox>). */ lightbox: boolean /** next/link — client-side navigation for internal links. Without it: a plain <a>. */ Link?: LinkComponent /** Turns a testimonials-collection document into an item. Default: quote, heading/author/name, text/role, media, rating. */ mapTestimonial?: (doc: Record<string, unknown>) => null | TestimonialItem + /** The first image of the leading block loads eagerly with high priority (LCP). Default true; `false` = never. */ + priorityImage?: boolean richText?: { className?: string } /** The project's sendForm server action (createSubmitAction) — the contact block needs it. */ sendForm?: SendFormAction @@ -70,6 +75,8 @@ export type BlockContext = { export type LibraryBlockProps<D> = { classNames?: PartClasses ctx: BlockContext + /** No block before this one shows an image (createPageRoute, blockPosition). */ + firstImage?: boolean isFirst?: boolean locale: string ui: BlockUi diff --git a/src/modules/block-library/ui/levels.ts b/src/modules/block-library/ui/levels.ts new file mode 100644 index 0000000..45081fe --- /dev/null +++ b/src/modules/block-library/ui/levels.ts @@ -0,0 +1,30 @@ +import type { BlockContext } from '../context.js' +import type { SectionHeaderData } from '../data.js' +import type { LibraryBlockSlug } from '../types.js' + +export type ItemHeadingLevel = 'h2' | 'h3' | 'h4' + +/** + * The heading level of a block's items (cards, plans, steps): one below the section heading — + * h3 under a section h2, h2 under the page h1 (first section) — and h2 when the block shows no + * heading of its own, so a list right under the page header never jumps from h1 to h3. + * `createBlockRegistry({ itemHeadings: { entryList: 'h3' } })` fixes a level per block. + */ +export function itemHeadingLevel( + slug: LibraryBlockSlug, + { ctx, header, isFirst }: { ctx: Pick<BlockContext, 'itemHeadings'>; header?: null | SectionHeaderData; isFirst?: boolean }, +): ItemHeadingLevel { + const own = ctx.itemHeadings?.[slug] + if (own) {return own} + return header?.heading && !isFirst ? 'h3' : 'h2' +} + +/** + * Whether the block's first image is the page's LCP image: the first section, or no block before it shows + * an image (`firstImage` from createPageRoute — e.g. an entry list under a page header without a picture). + * `createBlockRegistry({ priorityImage: false })` turns it off. + */ +export function leadsWithImage({ ctx, firstImage, isFirst }: { ctx: Pick<BlockContext, 'priorityImage'>; firstImage?: boolean; isFirst?: boolean }): boolean { + if (ctx.priorityImage === false) {return false} + return Boolean(firstImage ?? isFirst) +} diff --git a/src/modules/blocks/index.ts b/src/modules/blocks/index.ts index 1d8cc81..7fe0df6 100644 --- a/src/modules/blocks/index.ts +++ b/src/modules/blocks/index.ts @@ -1,3 +1,4 @@ +export { blockHasImage, blockPosition } from './position.js' export { RenderBlocks } from './RenderBlocks.js' export type { RenderBlocksProps } from './RenderBlocks.js' export { buildSectionHeaderField, buildSectionSettingsField } from './sectionFields.js' diff --git a/src/modules/blocks/position.ts b/src/modules/blocks/position.ts new file mode 100644 index 0000000..77dae3a --- /dev/null +++ b/src/modules/blocks/position.ts @@ -0,0 +1,27 @@ +import type { BlockData } from './types.js' + +const isImage = (v: unknown): boolean => { + if (!v || typeof v !== 'object') {return false} + const doc = v as { height?: unknown; mimeType?: unknown; url?: unknown; width?: unknown } + if (typeof doc.url !== 'string') {return false} + if (typeof doc.mimeType === 'string') {return doc.mimeType.startsWith('image/')} + return typeof doc.height === 'number' && typeof doc.width === 'number' +} + +/** True when the block's data holds a populated image anywhere (media, items[].media …). */ +export function blockHasImage(value: unknown, depth = 0): boolean { + if (depth > 6 || !value || typeof value !== 'object') {return false} + if (isImage(value)) {return true} + return (Array.isArray(value) ? value : Object.values(value)).some((v) => blockHasImage(v, depth + 1)) +} + +/** + * Where a block sits on the page, for headings and the LCP image: + * - `isFirst` — the first section: its heading is the page's only h1; + * - `firstImage` — no block before it shows an image, so its first image is likely the page's LCP image + * (e.g. an entry list under a page header without a picture) and should load eagerly with high priority. + * createPageRoute passes both to every block; use it in your own `enhanceProps`. + */ +export function blockPosition({ allBlocks, index }: { allBlocks: BlockData[]; index: number }): { firstImage: boolean; isFirst: boolean } { + return { firstImage: !allBlocks.slice(0, index).some((b) => blockHasImage(b)), isFirst: index === 0 } +} diff --git a/src/modules/frontend/pageRoute.tsx b/src/modules/frontend/pageRoute.tsx index 9a64645..3743b34 100644 --- a/src/modules/frontend/pageRoute.tsx +++ b/src/modules/frontend/pageRoute.tsx @@ -4,6 +4,7 @@ import type { BlockComponentMap, BlockData } from '../blocks/types.js' import type { ResolvedRoute } from '../content/index.js' import type { ContentHelpers, PageJsonLdOptions } from './createContentHelpers.js' +import { blockPosition } from '../blocks/position.js' import { RenderBlocks } from '../blocks/RenderBlocks.js' import { constructionNoticeHref, isPathVisibleIn } from '../construction/logic.js' import { LocaleView } from '../pages/LocaleView.js' @@ -19,8 +20,9 @@ type BlockPropsContext = { doc: Record<string, unknown>; locale: string } export type PageRouteOptions = { /** - * Props for every block on top of `locale` and `isFirst` (true for the first - * section — its heading is the page's only h1), computed once per page — + * Props for every block on top of `locale`, `isFirst` (true for the first + * section — its heading is the page's only h1) and `firstImage` (no block before it + * shows an image — its first image is the LCP image, blockPosition), computed once per page — * e.g. `{ formTexts, sendForm }` for form blocks. */ blockProps?: (ctx: BlockPropsContext) => Promise<Record<string, unknown>> | Record<string, unknown> @@ -138,7 +140,7 @@ export function createPageRoute(helpers: Helpers, options: PageRouteOptions) { <RenderBlocks blocks={doc[layoutField] as BlockData[] | undefined} components={blocks} - enhanceProps={({ index }) => ({ locale, ...extra, isFirst: index === 0 })} + enhanceProps={(at) => ({ locale, ...extra, ...blockPosition(at) })} /> ) const custom = render ? await render({ blocks: rendered, locale, route, segments }) : undefined @@ -190,7 +192,7 @@ async function notFoundView(helpers: NotFoundHelpers, options: NotFoundViewOptio const layout = doc?.[layoutField] as BlockData[] | undefined if (!doc || !layout?.length) {return typeof fallback === 'function' ? fallback(locale) : fallback} const extra = blockProps ? await blockProps({ doc, locale }) : {} - return <RenderBlocks blocks={layout} components={blocks} enhanceProps={({ index }) => ({ locale, ...extra, isFirst: index === 0 })} /> + return <RenderBlocks blocks={layout} components={blocks} enhanceProps={(at) => ({ locale, ...extra, ...blockPosition(at) })} /> } /** diff --git a/src/modules/seed/seeder.ts b/src/modules/seed/seeder.ts index 405c245..4c2ed25 100644 --- a/src/modules/seed/seeder.ts +++ b/src/modules/seed/seeder.ts @@ -431,7 +431,9 @@ export function createSeeder(payload: BasePayload, options: SeederOptions = {}): const fieldOf = (name: string) => (global?.flattenedFields as { defaultValue?: unknown; name?: string; type?: string }[] | undefined)?.find((f) => f.name === name) const cur = await readSeedTarget(payload, target, defaultLocale) // Empty, or a choice still at its default value (e.g. Theme → light): never text an editor wrote. - const empty = Object.keys(data).filter((k) => isUnsetValue(cur[k], fieldOf(k))) + // A field already holding exactly the seeded value is left alone (no write, reported as skip). + const same = (k: string) => JSON.stringify(cur[k]) === JSON.stringify(localize(data[k], defaultLocale, cur[k], codes)) + const empty = Object.keys(data).filter((k) => isUnsetValue(cur[k], fieldOf(k)) && !same(k)) let keys = empty let edited: null | string = null if (update) { diff --git a/test/blockLibraryRender.test.ts b/test/blockLibraryRender.test.ts index 0720aa1..03f6ecb 100644 --- a/test/blockLibraryRender.test.ts +++ b/test/blockLibraryRender.test.ts @@ -41,7 +41,7 @@ const link = (label: string) => ({ type: 'internal' as const, appearance: 'prima const links = [{ id: 'l1', link: link('Contact us') }] const content: BlockContent = { - getEntries: vi.fn(async () => ({ docs: [{ id: 7, slug: 'first', publishedAt: '2026-10-01T00:00:00.000Z', title: 'First post' }], hasNextPage: false, hasPrevPage: false, page: 1, totalDocs: 1, totalPages: 1 })), + getEntries: vi.fn(async () => ({ docs: [{ id: 7, slug: 'first', media: image('Cover'), publishedAt: '2026-10-01T00:00:00.000Z', title: 'First post' }, { id: 8, slug: 'second', media: image('Second'), title: 'Second post' }], hasNextPage: false, hasPrevPage: false, page: 1, totalDocs: 1, totalPages: 1 })), getFormTexts: vi.fn(async () => ({})), getLinkOptions: vi.fn(async () => ({ config: { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'PL' }] }, locale: 'pl' }) as never), resolveLink: (l) => { @@ -251,6 +251,37 @@ describe('block details', () => { expect(await render(block('cta'))).not.toContain('data-nosnippet') }) + test('item headings follow the section: h3 under a section heading, h2 without one (no h1 → h3 jump)', async () => { + const under = await render(block('entryList')) + expect(under).toMatch(/<h3 class="font-heading text-h4[^"]*"><a /) + const bare = await render(block('entryList', SAMPLES.entryList, { header: null })) + expect(bare).not.toContain('<h3') + expect(bare).toMatch(/<h2 class="font-heading text-h4[^"]*"><a /) + // First section with a heading: section h1, items h2. + const first = await render(block('featureGrid', SAMPLES.featureGrid, { isFirst: true })) + expect(first).toContain('<h1') + expect(first).toMatch(/<h2 class="font-heading text-h4/) + for (const slug of ['featureGrid', 'pricing', 'steps', 'team']) { + expect(await render(block(slug, SAMPLES[slug], { header: null })), slug).not.toContain('<h3') + } + const fixed = createBlockRegistry(content, { itemHeadings: { entryList: 'h4' } }) + expect(await render(h(fixed.entryList, { blockType: 'entryList', locale: 'en', ...SAMPLES.entryList }))).toContain('<h4') + }) + + test('the first image of the block that leads the page loads first (LCP); one per block, can be turned off', async () => { + const eager = /loading="eager"/g + // An entry list under a page header without a picture: firstImage from createPageRoute. + const lead = await render(block('entryList', SAMPLES.entryList, { firstImage: true, header: null })) + expect(lead.match(eager)).toHaveLength(1) + expect(lead).toContain('fetchPriority="high"') + expect(await render(block('entryList'))).not.toMatch(eager) + for (const slug of ['featureGrid', 'gallery', 'team', 'textMedia']) { + expect((await render(block(slug, SAMPLES[slug], { firstImage: true }))).match(eager), slug).toHaveLength(1) + } + const off = createBlockRegistry(content, { priorityImage: false }) + expect(await render(h(off.hero, { blockType: 'hero', isFirst: true, locale: 'en', ...SAMPLES.hero }))).not.toMatch(eager) + }) + test('classNames replace one part’s classes', async () => { const map = createBlockRegistry(content, { classNames: { faq: { item: 'my-item' } } }) const html = await render(h(map.faq, { blockType: 'faq', locale: 'en', ...SAMPLES.faq })) diff --git a/test/blockPosition.test.ts b/test/blockPosition.test.ts new file mode 100644 index 0000000..1b69b5a --- /dev/null +++ b/test/blockPosition.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, test } from 'vitest' + +import { blockHasImage, blockPosition } from '../src/index.js' + +const image = { height: 600, mimeType: 'image/jpeg', url: '/api/media/file/a.jpg', width: 900 } + +describe('blockPosition', () => { + const blocks = [ + { blockType: 'hero', header: { heading: 'Blog' }, media: null, variant: 'page' }, + { blockType: 'entryList', entryCollection: 'posts' }, + { blockType: 'gallery', items: [{ media: image }] }, + { blockType: 'cta', media: 7 }, + ] + + test('isFirst only for the first block; firstImage until a block shows an image', () => { + expect(blocks.map((_, index) => blockPosition({ allBlocks: blocks, index }))).toEqual([ + { firstImage: true, isFirst: true }, + { firstImage: true, isFirst: false }, + { firstImage: true, isFirst: false }, + { firstImage: false, isFirst: false }, + ]) + }) + + test('blockHasImage: populated images anywhere in the data; ids and videos do not count', () => { + expect(blockHasImage({ items: [{ media: image }] })).toBe(true) + expect(blockHasImage({ media: 7 })).toBe(false) + expect(blockHasImage({ media: { mimeType: 'video/mp4', url: '/v.mp4' } })).toBe(false) + }) +}) diff --git a/test/integration.test.ts b/test/integration.test.ts index 9d484d5..82c6c97 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -246,6 +246,10 @@ describe('one-call helpers — layout, page, GEO routes', () => { const blocksEl = el.props.children[1] as { props: { enhanceProps: (a: { allBlocks: never[]; block: never; index: number }) => Record<string, unknown> } } expect(blocksEl.props.enhanceProps({ allBlocks: [], block: {} as never, index: 0 })).toMatchObject({ isFirst: true, locale: 'pl' }) expect(blocksEl.props.enhanceProps({ allBlocks: [], block: {} as never, index: 1 }).isFirst).toBe(false) + // …and whether a block before them shows an image (the LCP image of a list under a page header without one). + const hero = { blockType: 'hero', media: { height: 1, mimeType: 'image/jpeg', url: '/a.jpg', width: 1 } } + expect(blocksEl.props.enhanceProps({ allBlocks: [{ blockType: 'hero' }, {}] as never[], block: {} as never, index: 1 }).firstImage).toBe(true) + expect(blocksEl.props.enhanceProps({ allBlocks: [hero, {}] as never[], block: {} as never, index: 1 }).firstImage).toBe(false) await expect(route.Page({ params: Promise.resolve({ slug: ['nie-ma'] }) })).rejects.toThrow('NEXT_NOT_FOUND') expect((await route.generateMetadata({ params: Promise.resolve({ slug: ['uslugi'] }) })).alternates?.canonical).toBe('https://acme.pl/uslugi') }) diff --git a/test/seed.test.ts b/test/seed.test.ts index e345261..b1ac821 100644 --- a/test/seed.test.ts +++ b/test/seed.test.ts @@ -256,6 +256,15 @@ describe('createSeeder', () => { expect(first.note).toBe('empty fields filled: mode, toggle') const look = (await payload.findGlobal({ slug: 'look' as never })) as { greeting: string; mode: string; toggle: boolean } expect(look).toMatchObject({ greeting: 'Hello', mode: 'system', toggle: false }) + // Seeding exactly what is stored (here the default) writes nothing and reports a skip, every run. + await payload.updateGlobal({ slug: 'look' as never, data: { mode: 'light', toggle: true } as never }) + const before = ((await payload.findGlobal({ slug: 'look' as never })) as { updatedAt: string }).updatedAt + for (let run = 0; run < 2; run++) { + expect(await seeder().fillGlobal('look', { mode: 'light', toggle: true })).toMatchObject({ status: 'skip (exists)' }) + } + expect(((await payload.findGlobal({ slug: 'look' as never })) as { updatedAt: string }).updatedAt).toBe(before) + // A different seeded value still replaces a choice at its default. + expect(await seeder().fillGlobal('look', { mode: 'system', toggle: true })).toMatchObject({ note: 'empty fields filled: mode', status: 'create' }) // An editor's choice that differs from the default stays. await payload.updateGlobal({ slug: 'look' as never, data: { mode: 'dark' } as never }) await seeder().fillGlobal('look', { mode: 'system' })