@bison-lab/payload-core 4.32.2 → 4.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +65 -3
  2. package/dist/block-library.d.mts +1 -1
  3. package/dist/block-library.mjs +1 -1
  4. package/dist/{block-thumbnails--AJzSdzJ.mjs → block-thumbnails-VRxpSXw1.mjs} +1 -1
  5. package/dist/{block-thumbnails--AJzSdzJ.mjs.map → block-thumbnails-VRxpSXw1.mjs.map} +1 -1
  6. package/dist/block-thumbnails-cli.mjs +1 -1
  7. package/dist/block-thumbnails.mjs +1 -1
  8. package/dist/{catalogue-BC_A9eLc.d.mts → catalogue-CEfYwTSK.d.mts} +1 -1
  9. package/dist/{catalogue-BC_A9eLc.d.mts.map → catalogue-CEfYwTSK.d.mts.map} +1 -1
  10. package/dist/{facet-field-DKzRCYrh.d.mts → facet-field-BvQp8Hzh.d.mts} +1 -1
  11. package/dist/{facet-field-DKzRCYrh.d.mts.map → facet-field-BvQp8Hzh.d.mts.map} +1 -1
  12. package/dist/{facet-field-Di1kNyzH.mjs → facet-field-Uf8S4yL1.mjs} +1 -1
  13. package/dist/{facet-field-Di1kNyzH.mjs.map → facet-field-Uf8S4yL1.mjs.map} +1 -1
  14. package/dist/identity-CN6EOeDM.mjs +180 -0
  15. package/dist/identity-CN6EOeDM.mjs.map +1 -0
  16. package/dist/index.d.mts +41 -6
  17. package/dist/index.d.mts.map +1 -1
  18. package/dist/index.mjs +145 -36
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/metadata.d.mts +14 -2
  21. package/dist/metadata.d.mts.map +1 -1
  22. package/dist/metadata.mjs +29 -3
  23. package/dist/metadata.mjs.map +1 -1
  24. package/dist/navigation.d.mts +1 -1
  25. package/dist/navigation.mjs +1 -1
  26. package/dist/og.d.mts +155 -0
  27. package/dist/og.d.mts.map +1 -0
  28. package/dist/og.mjs +282 -0
  29. package/dist/og.mjs.map +1 -0
  30. package/dist/{identity-8doWYeRn.mjs → preview-Br1SQCKn.mjs} +4 -179
  31. package/dist/preview-Br1SQCKn.mjs.map +1 -0
  32. package/dist/preview-Cgbh9eAq.d.mts +113 -0
  33. package/dist/preview-Cgbh9eAq.d.mts.map +1 -0
  34. package/dist/published-BLXCep6Z.d.mts +26 -0
  35. package/dist/published-BLXCep6Z.d.mts.map +1 -0
  36. package/dist/{published-CcW9bqLJ.mjs → published-CEuK5ym6.mjs} +1 -1
  37. package/dist/{published-CcW9bqLJ.mjs.map → published-CEuK5ym6.mjs.map} +1 -1
  38. package/dist/published-DgAzpDSG.mjs +31 -0
  39. package/dist/published-DgAzpDSG.mjs.map +1 -0
  40. package/dist/{published-IX1-6JEa.d.mts → published-Dsg-HX-v.d.mts} +1 -1
  41. package/dist/{published-IX1-6JEa.d.mts.map → published-Dsg-HX-v.d.mts.map} +1 -1
  42. package/dist/{published-niJkPGjE.mjs → published-QyTcDznE.mjs} +1 -1
  43. package/dist/{published-niJkPGjE.mjs.map → published-QyTcDznE.mjs.map} +1 -1
  44. package/dist/root-page-key-B86JwL8Z.mjs +32 -0
  45. package/dist/root-page-key-B86JwL8Z.mjs.map +1 -0
  46. package/dist/seo.d.mts +216 -0
  47. package/dist/seo.d.mts.map +1 -0
  48. package/dist/seo.mjs +155 -0
  49. package/dist/seo.mjs.map +1 -0
  50. package/dist/share-image-C8ZtIcU8.mjs +19 -0
  51. package/dist/share-image-C8ZtIcU8.mjs.map +1 -0
  52. package/dist/taxonomy.d.mts +1 -1
  53. package/dist/taxonomy.mjs +1 -1
  54. package/dist/theme.d.mts +3 -22
  55. package/dist/theme.d.mts.map +1 -1
  56. package/dist/theme.mjs +3 -28
  57. package/dist/theme.mjs.map +1 -1
  58. package/dist/{title-BvjHeRo5.d.mts → title-C8ppEDlc.d.mts} +1 -1
  59. package/dist/{title-BvjHeRo5.d.mts.map → title-C8ppEDlc.d.mts.map} +1 -1
  60. package/dist/title-DJ7C48gq.mjs +21 -0
  61. package/dist/title-DJ7C48gq.mjs.map +1 -0
  62. package/dist/{preview-D-G8PEEB.d.mts → types-D6jQql5Z.d.mts} +3 -110
  63. package/dist/types-D6jQql5Z.d.mts.map +1 -0
  64. package/dist/wireframe-cli.mjs +1 -1
  65. package/dist/{wireframe-ApjwNWAN.mjs → wireframe-sJW8Q4NS.mjs} +1 -1
  66. package/dist/{wireframe-ApjwNWAN.mjs.map → wireframe-sJW8Q4NS.mjs.map} +1 -1
  67. package/dist/wireframe.mjs +1 -1
  68. package/package.json +23 -5
  69. package/dist/identity-8doWYeRn.mjs.map +0 -1
  70. package/dist/preview-D-G8PEEB.d.mts.map +0 -1
  71. package/dist/share-image-C4ILz4p2.mjs +0 -37
  72. package/dist/share-image-C4ILz4p2.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"published-niJkPGjE.mjs","names":["PACKAGE_SLUGS"],"sources":["../src/block-library/controls.ts","../src/block-library/types.ts","../src/block-library/catalogue.ts","../src/block-library/published.ts"],"sourcesContent":["import type { BlockLibraryEntry, BlockLibraryKind } from \"./types\";\n\n/**\n * Which of the four section settings a block offers its editors. The\n * settings group on every page block keeps all four fields, so the page\n * schema never moves; a tick off hides the control in the editor and the\n * renderer ignores its stored value (payload-blocks, BIS-138). The choice\n * lives on the Block library row, seeded from the catalogue, so turning\n * one control off for one block is a Save, not a release (BIS-136).\n */\nexport const SECTION_CONTROL_KEYS = [\"background\", \"spacing\", \"anchor\", \"hidden\"] as const;\n\nexport type SectionControlKey = (typeof SECTION_CONTROL_KEYS)[number];\n\nexport type SectionControls = Record<SectionControlKey, boolean>;\n\n/** The words the settings fold uses, so the ticks read as the controls they hide. */\nexport const SECTION_CONTROL_LABELS: Record<SectionControlKey, string> = {\n background: \"Background\",\n spacing: \"Spacing\",\n anchor: \"Anchor\",\n hidden: \"Hidden\",\n};\n\n/** A section: every control. Also what a slug no catalogue knows gets. */\nexport const DEFAULT_SECTION_CONTROLS: SectionControls = {\n background: true,\n spacing: true,\n anchor: true,\n hidden: true,\n};\n\n/**\n * A hero: Anchor only. Background would compete with the hero's own tone,\n * Spacing is header clearance the editor should not change, and a hidden\n * hero is a published page with no opening.\n */\nexport const HERO_SECTION_CONTROLS: SectionControls = {\n background: false,\n spacing: false,\n anchor: true,\n hidden: false,\n};\n\n/** A navbar is not a section; the ticks do not render on its card. */\nexport const NO_SECTION_CONTROLS: SectionControls = {\n background: false,\n spacing: false,\n anchor: false,\n hidden: false,\n};\n\nexport function defaultSectionControls(kind: BlockLibraryKind): SectionControls {\n if (kind === \"hero\") return { ...HERO_SECTION_CONTROLS };\n if (kind === \"navbar\") return { ...NO_SECTION_CONTROLS };\n return { ...DEFAULT_SECTION_CONTROLS };\n}\n\n/** The entry's kind, from `kind` or else its category. */\nexport function kindOf(entry: Pick<BlockLibraryEntry, \"kind\" | \"category\">): BlockLibraryKind {\n return entry.kind ?? (entry.category === \"hero\" ? \"hero\" : entry.category === \"navigation\" ? \"navbar\" : \"section\");\n}\n\n/**\n * Reads four booleans off a stored or partial value, taking `fallback` for\n * any key that is absent or not a boolean. A row saved before the columns\n * existed, or an entry that names only one key, resolves this way.\n */\nexport function sectionControlsOf(value: unknown, fallback: SectionControls): SectionControls {\n const source = value && typeof value === \"object\" ? (value as Record<string, unknown>) : {};\n const out = { ...fallback };\n for (const key of SECTION_CONTROL_KEYS) {\n if (typeof source[key] === \"boolean\") out[key] = source[key] as boolean;\n }\n return out;\n}\n\n/** The catalogue default for one entry: its own `sectionControls` over the kind's. */\nexport function entrySectionControls(entry: BlockLibraryEntry): SectionControls {\n return sectionControlsOf(entry.sectionControls, defaultSectionControls(kindOf(entry)));\n}\n","import type { SectionControls } from \"./controls\";\n\nexport const BLOCK_LIBRARY_SLUG = \"block-library\";\n\nexport const BLOCK_LIBRARY_CATEGORIES = [\n { id: \"hero\", label: \"Hero\" },\n { id: \"feature\", label: \"Feature\" },\n { id: \"process\", label: \"Process\" },\n { id: \"faq\", label: \"FAQ\" },\n { id: \"testimonials\", label: \"Testimonials\" },\n { id: \"stats\", label: \"Stats\" },\n { id: \"content\", label: \"Content\" },\n { id: \"contact\", label: \"Contact\" },\n { id: \"cta\", label: \"CTA\" },\n { id: \"navigation\", label: \"Navigation\" },\n] as const;\n\nexport type BlockLibraryCategoryId = (typeof BLOCK_LIBRARY_CATEGORIES)[number][\"id\"];\n\nexport type BlockLibraryKind = \"hero\" | \"section\" | \"navbar\";\n\n/**\n * Package catalogue. `megaMenu` and `navLink` are header item blocks, not\n * cards. Navigation's card is `floatingNav`. The preview route is SPI-53.\n */\nexport const PACKAGE_BLOCK_SLUGS = [\n \"hero\",\n \"heroSweep\",\n \"heroCompact\",\n \"heroSimple\",\n \"showcasePanels\",\n \"featureHighlights\",\n \"featureChecklist\",\n \"processSteps\",\n \"faqColumns\",\n \"testimonialMasonry\",\n \"testimonialCarousel\",\n \"statsBand\",\n \"richText\",\n \"video\",\n \"nap\",\n \"inquiryForm\",\n \"ctaBand\",\n \"logoCloud\",\n \"gallery\",\n \"floatingNav\",\n] as const;\n\nexport type PackageBlockSlug = (typeof PACKAGE_BLOCK_SLUGS)[number];\n\nexport interface BlockLibraryEntry {\n slug: string;\n label: string;\n category: string;\n /** Defaults from the category: hero, navbar for navigation, otherwise section. */\n kind?: BlockLibraryKind;\n supportsMega?: boolean;\n sample?: unknown;\n /**\n * Which section settings the block offers, as the catalogue default its\n * row is seeded with. A key left out follows `kind`: a hero offers\n * Anchor only, a section all four, a navbar none. The row is what an\n * Admin then edits; this is only where it starts.\n */\n sectionControls?: Partial<SectionControls>;\n /**\n * The block's picture in Payload's Add Block drawer: a URL the site serves,\n * such as a screenshot `bison-block-thumbnails --out-dir public/…` wrote.\n * `blockDrawer()` sets it as the block's `admin.images.thumbnail` unless\n * the block config already has one. Package blocks ship theirs; a site\n * extra passes its own.\n */\n thumbnail?: string;\n}\n\nexport interface BlockLibraryRow {\n id: string;\n slug: string;\n label: string;\n category: string;\n enabled: boolean;\n kind: BlockLibraryKind;\n /** Four checkboxes beside Enabled. Hidden stays off on a hero row. */\n sectionControls: SectionControls;\n}\n\n/** The Block library Global as `findGlobal` returns it; rows are read loosely. */\nexport interface BlockLibraryDoc {\n blocks?: unknown;\n}\n\nexport interface BlockLibraryHolder {\n title?: string | null;\n slug?: string | null;\n}\n\n/** A draft that still holds a slug: a collection document or a Global. */\nexport interface BlockLibraryDraftHolder extends BlockLibraryHolder {\n collection?: string;\n id?: string | number;\n global?: string;\n}\n\n/** Where a slug is used. `published` refuses a disable; `drafts` are stripped. */\nexport interface BlockLibraryUsage {\n published: BlockLibraryHolder[];\n drafts: BlockLibraryDraftHolder[];\n}\n","import {\n DEFAULT_SECTION_CONTROLS,\n defaultSectionControls,\n entrySectionControls,\n HERO_SECTION_CONTROLS,\n kindOf,\n NO_SECTION_CONTROLS,\n sectionControlsOf,\n type SectionControls,\n} from \"./controls\";\nimport type {\n BlockLibraryDoc,\n BlockLibraryEntry,\n BlockLibraryHolder,\n BlockLibraryKind,\n BlockLibraryRow,\n} from \"./types\";\nimport { PACKAGE_BLOCK_SLUGS } from \"./types\";\n\nconst NOT_CATALOGUE = new Set([\"megaMenu\", \"navLink\"]);\n\n/**\n * Section controls are written out per entry so the defaults are read here,\n * not inferred: heroes Anchor only, sections all four, the navbar none.\n */\nconst PACKAGE_BLOCKS: readonly BlockLibraryEntry[] = [\n { slug: \"hero\", label: \"Hero\", category: \"hero\", kind: \"hero\", sectionControls: HERO_SECTION_CONTROLS },\n { slug: \"heroSweep\", label: \"Sweep hero\", category: \"hero\", kind: \"hero\", sectionControls: HERO_SECTION_CONTROLS },\n { slug: \"heroCompact\", label: \"Compact hero\", category: \"hero\", kind: \"hero\", sectionControls: HERO_SECTION_CONTROLS },\n { slug: \"heroSimple\", label: \"Simple hero\", category: \"hero\", kind: \"hero\", sectionControls: HERO_SECTION_CONTROLS },\n { slug: \"showcasePanels\", label: \"Showcase panels\", category: \"feature\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"featureHighlights\", label: \"Feature highlights\", category: \"feature\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"featureChecklist\", label: \"Feature checklist\", category: \"feature\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"processSteps\", label: \"Process steps\", category: \"process\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"faqColumns\", label: \"FAQ\", category: \"faq\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"testimonialMasonry\", label: \"Testimonials\", category: \"testimonials\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"testimonialCarousel\", label: \"Testimonial carousel\", category: \"testimonials\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"statsBand\", label: \"Stats\", category: \"stats\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"richText\", label: \"Rich text\", category: \"content\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"video\", label: \"Video\", category: \"content\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"nap\", label: \"Contact\", category: \"contact\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"inquiryForm\", label: \"Inquiry form\", category: \"contact\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"ctaBand\", label: \"CTA band\", category: \"cta\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"logoCloud\", label: \"Logo cloud\", category: \"content\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"gallery\", label: \"Gallery\", category: \"content\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"floatingNav\", label: \"Floating navbar\", category: \"navigation\", kind: \"navbar\", supportsMega: true, sectionControls: NO_SECTION_CONTROLS },\n];\n\nexport interface BlockLibraryOptions {\n blocks?: readonly BlockLibraryEntry[];\n previewPath: (slug: string) => string;\n}\n\nexport interface BlockLibraryCheck {\n originals?: readonly BlockLibraryRow[];\n /** Published documents that hold a slug being turned off. Any refuses. */\n holders?: readonly BlockLibraryHolder[];\n /** Drafts that hold it. Named in a refusal; never a reason to refuse. */\n drafts?: readonly BlockLibraryHolder[];\n pages?: unknown[];\n}\n\nconst PACKAGE_SLUGS = new Set(PACKAGE_BLOCKS.map((entry) => entry.slug));\n\n/**\n * The package entries, then the site's extras. An extra whose slug the\n * package ships replaces that package entry in its place: a site that\n * registered its own block before the package shipped one under the same\n * slug still renders its own config, so its label, category, controls,\n * picture and sample are the true ones. A release that adds such a block\n * therefore never yields two rows for one slug, and never relabels the\n * site's block as the package's.\n */\nexport function blockLibraryCatalogue(extras: readonly BlockLibraryEntry[] = []): BlockLibraryEntry[] {\n const own = extras.filter((entry) => !NOT_CATALOGUE.has(entry.slug));\n const shadows = new Map(own.filter((entry) => PACKAGE_SLUGS.has(entry.slug)).map((entry) => [entry.slug, entry]));\n return [\n ...PACKAGE_BLOCKS.map((entry) => shadows.get(entry.slug) ?? { ...entry, sectionControls: { ...entry.sectionControls } }),\n ...own.filter((entry) => !PACKAGE_SLUGS.has(entry.slug)),\n ];\n}\n\nexport function defaultBlockLibraryValue(options: BlockLibraryOptions): BlockLibraryRow[] {\n return blockLibraryCatalogue(options.blocks).map((entry) => toRow(entry, true));\n}\n\nfunction toRow(entry: BlockLibraryEntry, enabled = true, sectionControls?: SectionControls): BlockLibraryRow {\n return {\n id: entry.slug,\n slug: entry.slug,\n label: entry.label,\n category: entry.category,\n enabled,\n kind: kindOf(entry),\n sectionControls: sectionControls ?? entrySectionControls(entry),\n };\n}\n\n/**\n * The stored rows, one per catalogue entry in catalogue order. A stored\n * `enabled` and each stored tick are kept; anything else (a row that is\n * not there, a column that did not exist when it was saved) takes the\n * entry's default. A block that arrives in a later release gets its\n * catalogue default this way, without a migration beyond the new columns.\n */\nexport function stampBlockLibrary(value: unknown, options: BlockLibraryOptions): BlockLibraryRow[] {\n const catalogue = blockLibraryCatalogue(options.blocks);\n const incoming = new Map<string, { enabled?: boolean; sectionControls?: unknown }>();\n if (Array.isArray(value)) {\n for (const item of value) {\n if (!item || typeof item !== \"object\" || !(\"slug\" in item)) continue;\n const slug = item.slug;\n if (typeof slug !== \"string\" || NOT_CATALOGUE.has(slug)) continue;\n if (!catalogue.some((entry) => entry.slug === slug)) continue;\n const row = item as { enabled?: unknown; sectionControls?: unknown };\n incoming.set(slug, {\n enabled: typeof row.enabled === \"boolean\" ? row.enabled : undefined,\n sectionControls: row.sectionControls,\n });\n }\n }\n return catalogue.map((entry) => {\n const stored = incoming.get(entry.slug);\n return toRow(\n entry,\n stored?.enabled ?? true,\n sectionControlsOf(stored?.sectionControls, entrySectionControls(entry)),\n );\n });\n}\n\nfunction isKind(value: unknown): value is BlockLibraryKind {\n return value === \"hero\" || value === \"section\" || value === \"navbar\";\n}\n\n/**\n * Every slug to the controls its row offers: the stored ticks when the\n * document holds the row, else the catalogue default. A stored row is kept\n * whether or not its slug is in the catalogue, so a site extra's saved\n * ticks are read without the site passing its `blocks` here (its stored\n * `kind` fills a key the row lacks). `extras` adds the catalogue default\n * for a site extra the document does not hold yet; `getSectionControls`\n * reads them off the Global's config. A slug in neither is absent from the\n * map, and a consumer treats that as every control\n * (`DEFAULT_SECTION_CONTROLS`). A disabled block keeps its ticks.\n */\nexport function sectionControlsFromLibrary(\n doc: BlockLibraryDoc | null | undefined,\n extras: readonly BlockLibraryEntry[] = [],\n): Record<string, SectionControls> {\n const rows = stampBlockLibrary(doc?.blocks, { blocks: extras, previewPath: () => \"\" });\n const map = Object.fromEntries(rows.map((row) => [row.slug, row.sectionControls]));\n const stored = Array.isArray(doc?.blocks) ? doc.blocks : [];\n for (const item of stored) {\n if (!item || typeof item !== \"object\") continue;\n const row = item as { slug?: unknown; kind?: unknown; sectionControls?: unknown };\n if (typeof row.slug !== \"string\" || !row.slug || NOT_CATALOGUE.has(row.slug) || row.slug in map) continue;\n map[row.slug] = sectionControlsOf(\n row.sectionControls,\n defaultSectionControls(isKind(row.kind) ? row.kind : \"section\"),\n );\n }\n return map;\n}\n\nfunction enabledOf(rows: readonly BlockLibraryRow[], kind: BlockLibraryKind): number {\n return rows.filter((row) => row.kind === kind && row.enabled).length;\n}\n\nfunction holderLabel(holder: BlockLibraryHolder): string {\n const title = holder.title?.trim() || \"Untitled\";\n const slug = holder.slug?.trim();\n return slug ? `${title} (${slug})` : title;\n}\n\n/**\n * Refuses Hidden on a hero row (a page cannot publish without its hero),\n * then a disable: the last hero, the last navbar, or a slug a published\n * document holds. Drafts alone never refuse; the Save that turns the slug\n * off strips them (`stripDrafts`). Pure — writes nothing.\n */\nexport async function validateBlockLibrary(\n value: unknown,\n options: BlockLibraryOptions,\n check: BlockLibraryCheck = {},\n): Promise<true | string> {\n const next = stampBlockLibrary(value, options);\n const hiddenHero = next.find((row) => row.kind === \"hero\" && row.sectionControls.hidden);\n if (hiddenHero) {\n return `${hiddenHero.label} cannot offer Hidden: a page cannot publish without its hero.`;\n }\n\n const previous = check.originals ?? defaultBlockLibraryValue(options);\n const turningOff = next.filter((row) => {\n const before = previous.find((entry) => entry.slug === row.slug);\n return before?.enabled !== false && row.enabled === false;\n });\n if (turningOff.length === 0) return true;\n\n if (turningOff.some((row) => row.kind === \"hero\") && enabledOf(next, \"hero\") === 0) {\n return \"Cannot disable the last hero.\";\n }\n if (turningOff.some((row) => row.kind === \"navbar\") && enabledOf(next, \"navbar\") === 0) {\n return \"Cannot disable the last navbar.\";\n }\n\n const holders = check.holders ?? [];\n if (holders.length > 0) {\n const names = holders.map(holderLabel).join(\", \");\n const slugs = turningOff.map((row) => row.label).join(\", \");\n const drafts = check.drafts ?? [];\n const draftNote =\n drafts.length > 0 ? ` Drafts also use it and were left as they are: ${drafts.map(holderLabel).join(\", \")}.` : \"\";\n return `Cannot disable ${slugs}. Still published on: ${names}. Remove it from those first.${draftNote}`;\n }\n\n return true;\n}\n\nexport function packageBlockSlugs(): readonly string[] {\n return PACKAGE_BLOCK_SLUGS;\n}\n","import type { Payload } from \"payload\";\n\nimport { sectionControlsFromLibrary } from \"./catalogue\";\nimport type { SectionControls } from \"./controls\";\nimport { BLOCK_LIBRARY_SLUG, PACKAGE_BLOCK_SLUGS, type BlockLibraryDoc, type BlockLibraryEntry } from \"./types\";\n\n/** The slice of `Payload` these readers need, so a test can pass a stub. */\nexport interface BlockLibraryReader {\n findGlobal: (args: { slug: string; depth: number; overrideAccess: boolean }) => Promise<unknown>;\n config?: { globals?: unknown };\n}\n\nconst PACKAGE_SLUGS = new Set<string>(PACKAGE_BLOCK_SLUGS);\n\n/**\n * A site's own Block library entries, read back off the registered Global:\n * `createBlockLibrary` keeps the rows it seeded (package and extras) on the\n * `blocks` field's `admin.custom.rows`, so a site block's catalogue default\n * is known here without the site passing `blocks` a second time. Package\n * slugs are left out (the catalogue already has them) unless the site\n * registered its own entry under one, which `siteSlugs` records.\n */\nexport function blockLibraryEntriesFromConfig(payload: Pick<BlockLibraryReader, \"config\">): BlockLibraryEntry[] {\n const globals = Array.isArray(payload.config?.globals) ? payload.config.globals : [];\n const library = globals.find(\n (global): global is { slug: string; fields?: unknown[] } =>\n typeof global === \"object\" && global !== null && (global as { slug?: unknown }).slug === BLOCK_LIBRARY_SLUG,\n );\n const blocks = (library?.fields ?? []).find(\n (field): field is { admin?: { custom?: { rows?: unknown; siteSlugs?: unknown } } } =>\n typeof field === \"object\" && field !== null && (field as { name?: unknown }).name === \"blocks\",\n );\n const rows = blocks?.admin?.custom?.rows;\n if (!Array.isArray(rows)) return [];\n const siteSlugs = blocks?.admin?.custom?.siteSlugs;\n const own = new Set(Array.isArray(siteSlugs) ? siteSlugs.filter((slug) => typeof slug === \"string\") : []);\n return rows.flatMap((row): BlockLibraryEntry[] => {\n if (!row || typeof row !== \"object\") return [];\n const { slug, label, category, kind, sectionControls } = row as Record<string, unknown>;\n if (typeof slug !== \"string\" || !slug || (PACKAGE_SLUGS.has(slug) && !own.has(slug))) return [];\n return [\n {\n slug,\n label: typeof label === \"string\" ? label : slug,\n category: typeof category === \"string\" ? category : \"content\",\n ...(kind === \"hero\" || kind === \"section\" || kind === \"navbar\" ? { kind } : {}),\n ...(sectionControls && typeof sectionControls === \"object\"\n ? { sectionControls: sectionControls as BlockLibraryEntry[\"sectionControls\"] }\n : {}),\n },\n ];\n });\n}\n\n/**\n * The Block library's section controls at request time, for a page route\n * to hand `RenderBlocks` as `sectionControls`. Access is overridden: the\n * Global is read by editors, and the page is read by everyone. A site\n * extra's stored ticks are kept, and one the document does not hold yet\n * takes its catalogue default from the Global's config; pass `extras` only\n * to add entries the config does not know.\n */\nexport async function getSectionControls(\n payload: BlockLibraryReader | Payload,\n extras: readonly BlockLibraryEntry[] = blockLibraryEntriesFromConfig(payload as BlockLibraryReader),\n): Promise<Record<string, SectionControls>> {\n const doc = (await payload.findGlobal({ slug: BLOCK_LIBRARY_SLUG, depth: 0, overrideAccess: true })) as\n | BlockLibraryDoc\n | null\n | undefined;\n return sectionControlsFromLibrary(doc, extras);\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,uBAAuB;CAAC;CAAc;CAAW;CAAU;CAAS;;AAOjF,MAAa,yBAA4D;CACvE,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,QAAQ;CACT;;AAGD,MAAa,2BAA4C;CACvD,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,QAAQ;CACT;;;;;;AAOD,MAAa,wBAAyC;CACpD,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,QAAQ;CACT;;AAGD,MAAa,sBAAuC;CAClD,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,QAAQ;CACT;AAED,SAAgB,uBAAuB,MAAyC;AAC9E,KAAI,SAAS,OAAQ,QAAO,EAAE,GAAG,uBAAuB;AACxD,KAAI,SAAS,SAAU,QAAO,EAAE,GAAG,qBAAqB;AACxD,QAAO,EAAE,GAAG,0BAA0B;;;AAIxC,SAAgB,OAAO,OAAuE;AAC5F,Q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/types.ts","../src/block-library/catalogue.ts","../src/block-library/published.ts"],"sourcesContent":["import type { BlockLibraryEntry, BlockLibraryKind } from \"./types\";\n\n/**\n * Which of the four section settings a block offers its editors. The\n * settings group on every page block keeps all four fields, so the page\n * schema never moves; a tick off hides the control in the editor and the\n * renderer ignores its stored value (payload-blocks, BIS-138). The choice\n * lives on the Block library row, seeded from the catalogue, so turning\n * one control off for one block is a Save, not a release (BIS-136).\n */\nexport const SECTION_CONTROL_KEYS = [\"background\", \"spacing\", \"anchor\", \"hidden\"] as const;\n\nexport type SectionControlKey = (typeof SECTION_CONTROL_KEYS)[number];\n\nexport type SectionControls = Record<SectionControlKey, boolean>;\n\n/** The words the settings fold uses, so the ticks read as the controls they hide. */\nexport const SECTION_CONTROL_LABELS: Record<SectionControlKey, string> = {\n background: \"Background\",\n spacing: \"Spacing\",\n anchor: \"Anchor\",\n hidden: \"Hidden\",\n};\n\n/** A section: every control. Also what a slug no catalogue knows gets. */\nexport const DEFAULT_SECTION_CONTROLS: SectionControls = {\n background: true,\n spacing: true,\n anchor: true,\n hidden: true,\n};\n\n/**\n * A hero: Anchor only. Background would compete with the hero's own tone,\n * Spacing is header clearance the editor should not change, and a hidden\n * hero is a published page with no opening.\n */\nexport const HERO_SECTION_CONTROLS: SectionControls = {\n background: false,\n spacing: false,\n anchor: true,\n hidden: false,\n};\n\n/** A navbar is not a section; the ticks do not render on its card. */\nexport const NO_SECTION_CONTROLS: SectionControls = {\n background: false,\n spacing: false,\n anchor: false,\n hidden: false,\n};\n\nexport function defaultSectionControls(kind: BlockLibraryKind): SectionControls {\n if (kind === \"hero\") return { ...HERO_SECTION_CONTROLS };\n if (kind === \"navbar\") return { ...NO_SECTION_CONTROLS };\n return { ...DEFAULT_SECTION_CONTROLS };\n}\n\n/** The entry's kind, from `kind` or else its category. */\nexport function kindOf(entry: Pick<BlockLibraryEntry, \"kind\" | \"category\">): BlockLibraryKind {\n return entry.kind ?? (entry.category === \"hero\" ? \"hero\" : entry.category === \"navigation\" ? \"navbar\" : \"section\");\n}\n\n/**\n * Reads four booleans off a stored or partial value, taking `fallback` for\n * any key that is absent or not a boolean. A row saved before the columns\n * existed, or an entry that names only one key, resolves this way.\n */\nexport function sectionControlsOf(value: unknown, fallback: SectionControls): SectionControls {\n const source = value && typeof value === \"object\" ? (value as Record<string, unknown>) : {};\n const out = { ...fallback };\n for (const key of SECTION_CONTROL_KEYS) {\n if (typeof source[key] === \"boolean\") out[key] = source[key] as boolean;\n }\n return out;\n}\n\n/** The catalogue default for one entry: its own `sectionControls` over the kind's. */\nexport function entrySectionControls(entry: BlockLibraryEntry): SectionControls {\n return sectionControlsOf(entry.sectionControls, defaultSectionControls(kindOf(entry)));\n}\n","import type { SectionControls } from \"./controls\";\n\nexport const BLOCK_LIBRARY_SLUG = \"block-library\";\n\nexport const BLOCK_LIBRARY_CATEGORIES = [\n { id: \"hero\", label: \"Hero\" },\n { id: \"feature\", label: \"Feature\" },\n { id: \"process\", label: \"Process\" },\n { id: \"faq\", label: \"FAQ\" },\n { id: \"testimonials\", label: \"Testimonials\" },\n { id: \"stats\", label: \"Stats\" },\n { id: \"content\", label: \"Content\" },\n { id: \"contact\", label: \"Contact\" },\n { id: \"cta\", label: \"CTA\" },\n { id: \"navigation\", label: \"Navigation\" },\n] as const;\n\nexport type BlockLibraryCategoryId = (typeof BLOCK_LIBRARY_CATEGORIES)[number][\"id\"];\n\nexport type BlockLibraryKind = \"hero\" | \"section\" | \"navbar\";\n\n/**\n * Package catalogue. `megaMenu` and `navLink` are header item blocks, not\n * cards. Navigation's card is `floatingNav`. The preview route is SPI-53.\n */\nexport const PACKAGE_BLOCK_SLUGS = [\n \"hero\",\n \"heroSweep\",\n \"heroCompact\",\n \"heroSimple\",\n \"showcasePanels\",\n \"featureHighlights\",\n \"featureChecklist\",\n \"processSteps\",\n \"faqColumns\",\n \"testimonialMasonry\",\n \"testimonialCarousel\",\n \"statsBand\",\n \"richText\",\n \"video\",\n \"nap\",\n \"inquiryForm\",\n \"ctaBand\",\n \"logoCloud\",\n \"gallery\",\n \"floatingNav\",\n] as const;\n\nexport type PackageBlockSlug = (typeof PACKAGE_BLOCK_SLUGS)[number];\n\nexport interface BlockLibraryEntry {\n slug: string;\n label: string;\n category: string;\n /** Defaults from the category: hero, navbar for navigation, otherwise section. */\n kind?: BlockLibraryKind;\n supportsMega?: boolean;\n sample?: unknown;\n /**\n * Which section settings the block offers, as the catalogue default its\n * row is seeded with. A key left out follows `kind`: a hero offers\n * Anchor only, a section all four, a navbar none. The row is what an\n * Admin then edits; this is only where it starts.\n */\n sectionControls?: Partial<SectionControls>;\n /**\n * The block's picture in Payload's Add Block drawer: a URL the site serves,\n * such as a screenshot `bison-block-thumbnails --out-dir public/…` wrote.\n * `blockDrawer()` sets it as the block's `admin.images.thumbnail` unless\n * the block config already has one. Package blocks ship theirs; a site\n * extra passes its own.\n */\n thumbnail?: string;\n}\n\nexport interface BlockLibraryRow {\n id: string;\n slug: string;\n label: string;\n category: string;\n enabled: boolean;\n kind: BlockLibraryKind;\n /** Four checkboxes beside Enabled. Hidden stays off on a hero row. */\n sectionControls: SectionControls;\n}\n\n/** The Block library Global as `findGlobal` returns it; rows are read loosely. */\nexport interface BlockLibraryDoc {\n blocks?: unknown;\n}\n\nexport interface BlockLibraryHolder {\n title?: string | null;\n slug?: string | null;\n}\n\n/** A draft that still holds a slug: a collection document or a Global. */\nexport interface BlockLibraryDraftHolder extends BlockLibraryHolder {\n collection?: string;\n id?: string | number;\n global?: string;\n}\n\n/** Where a slug is used. `published` refuses a disable; `drafts` are stripped. */\nexport interface BlockLibraryUsage {\n published: BlockLibraryHolder[];\n drafts: BlockLibraryDraftHolder[];\n}\n","import {\n DEFAULT_SECTION_CONTROLS,\n defaultSectionControls,\n entrySectionControls,\n HERO_SECTION_CONTROLS,\n kindOf,\n NO_SECTION_CONTROLS,\n sectionControlsOf,\n type SectionControls,\n} from \"./controls\";\nimport type {\n BlockLibraryDoc,\n BlockLibraryEntry,\n BlockLibraryHolder,\n BlockLibraryKind,\n BlockLibraryRow,\n} from \"./types\";\nimport { PACKAGE_BLOCK_SLUGS } from \"./types\";\n\nconst NOT_CATALOGUE = new Set([\"megaMenu\", \"navLink\"]);\n\n/**\n * Section controls are written out per entry so the defaults are read here,\n * not inferred: heroes Anchor only, sections all four, the navbar none.\n */\nconst PACKAGE_BLOCKS: readonly BlockLibraryEntry[] = [\n { slug: \"hero\", label: \"Hero\", category: \"hero\", kind: \"hero\", sectionControls: HERO_SECTION_CONTROLS },\n { slug: \"heroSweep\", label: \"Sweep hero\", category: \"hero\", kind: \"hero\", sectionControls: HERO_SECTION_CONTROLS },\n { slug: \"heroCompact\", label: \"Compact hero\", category: \"hero\", kind: \"hero\", sectionControls: HERO_SECTION_CONTROLS },\n { slug: \"heroSimple\", label: \"Simple hero\", category: \"hero\", kind: \"hero\", sectionControls: HERO_SECTION_CONTROLS },\n { slug: \"showcasePanels\", label: \"Showcase panels\", category: \"feature\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"featureHighlights\", label: \"Feature highlights\", category: \"feature\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"featureChecklist\", label: \"Feature checklist\", category: \"feature\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"processSteps\", label: \"Process steps\", category: \"process\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"faqColumns\", label: \"FAQ\", category: \"faq\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"testimonialMasonry\", label: \"Testimonials\", category: \"testimonials\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"testimonialCarousel\", label: \"Testimonial carousel\", category: \"testimonials\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"statsBand\", label: \"Stats\", category: \"stats\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"richText\", label: \"Rich text\", category: \"content\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"video\", label: \"Video\", category: \"content\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"nap\", label: \"Contact\", category: \"contact\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"inquiryForm\", label: \"Inquiry form\", category: \"contact\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"ctaBand\", label: \"CTA band\", category: \"cta\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"logoCloud\", label: \"Logo cloud\", category: \"content\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"gallery\", label: \"Gallery\", category: \"content\", kind: \"section\", sectionControls: DEFAULT_SECTION_CONTROLS },\n { slug: \"floatingNav\", label: \"Floating navbar\", category: \"navigation\", kind: \"navbar\", supportsMega: true, sectionControls: NO_SECTION_CONTROLS },\n];\n\nexport interface BlockLibraryOptions {\n blocks?: readonly BlockLibraryEntry[];\n previewPath: (slug: string) => string;\n}\n\nexport interface BlockLibraryCheck {\n originals?: readonly BlockLibraryRow[];\n /** Published documents that hold a slug being turned off. Any refuses. */\n holders?: readonly BlockLibraryHolder[];\n /** Drafts that hold it. Named in a refusal; never a reason to refuse. */\n drafts?: readonly BlockLibraryHolder[];\n pages?: unknown[];\n}\n\nconst PACKAGE_SLUGS = new Set(PACKAGE_BLOCKS.map((entry) => entry.slug));\n\n/**\n * The package entries, then the site's extras. An extra whose slug the\n * package ships replaces that package entry in its place: a site that\n * registered its own block before the package shipped one under the same\n * slug still renders its own config, so its label, category, controls,\n * picture and sample are the true ones. A release that adds such a block\n * therefore never yields two rows for one slug, and never relabels the\n * site's block as the package's.\n */\nexport function blockLibraryCatalogue(extras: readonly BlockLibraryEntry[] = []): BlockLibraryEntry[] {\n const own = extras.filter((entry) => !NOT_CATALOGUE.has(entry.slug));\n const shadows = new Map(own.filter((entry) => PACKAGE_SLUGS.has(entry.slug)).map((entry) => [entry.slug, entry]));\n return [\n ...PACKAGE_BLOCKS.map((entry) => shadows.get(entry.slug) ?? { ...entry, sectionControls: { ...entry.sectionControls } }),\n ...own.filter((entry) => !PACKAGE_SLUGS.has(entry.slug)),\n ];\n}\n\nexport function defaultBlockLibraryValue(options: BlockLibraryOptions): BlockLibraryRow[] {\n return blockLibraryCatalogue(options.blocks).map((entry) => toRow(entry, true));\n}\n\nfunction toRow(entry: BlockLibraryEntry, enabled = true, sectionControls?: SectionControls): BlockLibraryRow {\n return {\n id: entry.slug,\n slug: entry.slug,\n label: entry.label,\n category: entry.category,\n enabled,\n kind: kindOf(entry),\n sectionControls: sectionControls ?? entrySectionControls(entry),\n };\n}\n\n/**\n * The stored rows, one per catalogue entry in catalogue order. A stored\n * `enabled` and each stored tick are kept; anything else (a row that is\n * not there, a column that did not exist when it was saved) takes the\n * entry's default. A block that arrives in a later release gets its\n * catalogue default this way, without a migration beyond the new columns.\n */\nexport function stampBlockLibrary(value: unknown, options: BlockLibraryOptions): BlockLibraryRow[] {\n const catalogue = blockLibraryCatalogue(options.blocks);\n const incoming = new Map<string, { enabled?: boolean; sectionControls?: unknown }>();\n if (Array.isArray(value)) {\n for (const item of value) {\n if (!item || typeof item !== \"object\" || !(\"slug\" in item)) continue;\n const slug = item.slug;\n if (typeof slug !== \"string\" || NOT_CATALOGUE.has(slug)) continue;\n if (!catalogue.some((entry) => entry.slug === slug)) continue;\n const row = item as { enabled?: unknown; sectionControls?: unknown };\n incoming.set(slug, {\n enabled: typeof row.enabled === \"boolean\" ? row.enabled : undefined,\n sectionControls: row.sectionControls,\n });\n }\n }\n return catalogue.map((entry) => {\n const stored = incoming.get(entry.slug);\n return toRow(\n entry,\n stored?.enabled ?? true,\n sectionControlsOf(stored?.sectionControls, entrySectionControls(entry)),\n );\n });\n}\n\nfunction isKind(value: unknown): value is BlockLibraryKind {\n return value === \"hero\" || value === \"section\" || value === \"navbar\";\n}\n\n/**\n * Every slug to the controls its row offers: the stored ticks when the\n * document holds the row, else the catalogue default. A stored row is kept\n * whether or not its slug is in the catalogue, so a site extra's saved\n * ticks are read without the site passing its `blocks` here (its stored\n * `kind` fills a key the row lacks). `extras` adds the catalogue default\n * for a site extra the document does not hold yet; `getSectionControls`\n * reads them off the Global's config. A slug in neither is absent from the\n * map, and a consumer treats that as every control\n * (`DEFAULT_SECTION_CONTROLS`). A disabled block keeps its ticks.\n */\nexport function sectionControlsFromLibrary(\n doc: BlockLibraryDoc | null | undefined,\n extras: readonly BlockLibraryEntry[] = [],\n): Record<string, SectionControls> {\n const rows = stampBlockLibrary(doc?.blocks, { blocks: extras, previewPath: () => \"\" });\n const map = Object.fromEntries(rows.map((row) => [row.slug, row.sectionControls]));\n const stored = Array.isArray(doc?.blocks) ? doc.blocks : [];\n for (const item of stored) {\n if (!item || typeof item !== \"object\") continue;\n const row = item as { slug?: unknown; kind?: unknown; sectionControls?: unknown };\n if (typeof row.slug !== \"string\" || !row.slug || NOT_CATALOGUE.has(row.slug) || row.slug in map) continue;\n map[row.slug] = sectionControlsOf(\n row.sectionControls,\n defaultSectionControls(isKind(row.kind) ? row.kind : \"section\"),\n );\n }\n return map;\n}\n\nfunction enabledOf(rows: readonly BlockLibraryRow[], kind: BlockLibraryKind): number {\n return rows.filter((row) => row.kind === kind && row.enabled).length;\n}\n\nfunction holderLabel(holder: BlockLibraryHolder): string {\n const title = holder.title?.trim() || \"Untitled\";\n const slug = holder.slug?.trim();\n return slug ? `${title} (${slug})` : title;\n}\n\n/**\n * Refuses Hidden on a hero row (a page cannot publish without its hero),\n * then a disable: the last hero, the last navbar, or a slug a published\n * document holds. Drafts alone never refuse; the Save that turns the slug\n * off strips them (`stripDrafts`). Pure — writes nothing.\n */\nexport async function validateBlockLibrary(\n value: unknown,\n options: BlockLibraryOptions,\n check: BlockLibraryCheck = {},\n): Promise<true | string> {\n const next = stampBlockLibrary(value, options);\n const hiddenHero = next.find((row) => row.kind === \"hero\" && row.sectionControls.hidden);\n if (hiddenHero) {\n return `${hiddenHero.label} cannot offer Hidden: a page cannot publish without its hero.`;\n }\n\n const previous = check.originals ?? defaultBlockLibraryValue(options);\n const turningOff = next.filter((row) => {\n const before = previous.find((entry) => entry.slug === row.slug);\n return before?.enabled !== false && row.enabled === false;\n });\n if (turningOff.length === 0) return true;\n\n if (turningOff.some((row) => row.kind === \"hero\") && enabledOf(next, \"hero\") === 0) {\n return \"Cannot disable the last hero.\";\n }\n if (turningOff.some((row) => row.kind === \"navbar\") && enabledOf(next, \"navbar\") === 0) {\n return \"Cannot disable the last navbar.\";\n }\n\n const holders = check.holders ?? [];\n if (holders.length > 0) {\n const names = holders.map(holderLabel).join(\", \");\n const slugs = turningOff.map((row) => row.label).join(\", \");\n const drafts = check.drafts ?? [];\n const draftNote =\n drafts.length > 0 ? ` Drafts also use it and were left as they are: ${drafts.map(holderLabel).join(\", \")}.` : \"\";\n return `Cannot disable ${slugs}. Still published on: ${names}. Remove it from those first.${draftNote}`;\n }\n\n return true;\n}\n\nexport function packageBlockSlugs(): readonly string[] {\n return PACKAGE_BLOCK_SLUGS;\n}\n","import type { Payload } from \"payload\";\n\nimport { sectionControlsFromLibrary } from \"./catalogue\";\nimport type { SectionControls } from \"./controls\";\nimport { BLOCK_LIBRARY_SLUG, PACKAGE_BLOCK_SLUGS, type BlockLibraryDoc, type BlockLibraryEntry } from \"./types\";\n\n/** The slice of `Payload` these readers need, so a test can pass a stub. */\nexport interface BlockLibraryReader {\n findGlobal: (args: { slug: string; depth: number; overrideAccess: boolean }) => Promise<unknown>;\n config?: { globals?: unknown };\n}\n\nconst PACKAGE_SLUGS = new Set<string>(PACKAGE_BLOCK_SLUGS);\n\n/**\n * A site's own Block library entries, read back off the registered Global:\n * `createBlockLibrary` keeps the rows it seeded (package and extras) on the\n * `blocks` field's `admin.custom.rows`, so a site block's catalogue default\n * is known here without the site passing `blocks` a second time. Package\n * slugs are left out (the catalogue already has them) unless the site\n * registered its own entry under one, which `siteSlugs` records.\n */\nexport function blockLibraryEntriesFromConfig(payload: Pick<BlockLibraryReader, \"config\">): BlockLibraryEntry[] {\n const globals = Array.isArray(payload.config?.globals) ? payload.config.globals : [];\n const library = globals.find(\n (global): global is { slug: string; fields?: unknown[] } =>\n typeof global === \"object\" && global !== null && (global as { slug?: unknown }).slug === BLOCK_LIBRARY_SLUG,\n );\n const blocks = (library?.fields ?? []).find(\n (field): field is { admin?: { custom?: { rows?: unknown; siteSlugs?: unknown } } } =>\n typeof field === \"object\" && field !== null && (field as { name?: unknown }).name === \"blocks\",\n );\n const rows = blocks?.admin?.custom?.rows;\n if (!Array.isArray(rows)) return [];\n const siteSlugs = blocks?.admin?.custom?.siteSlugs;\n const own = new Set(Array.isArray(siteSlugs) ? siteSlugs.filter((slug) => typeof slug === \"string\") : []);\n return rows.flatMap((row): BlockLibraryEntry[] => {\n if (!row || typeof row !== \"object\") return [];\n const { slug, label, category, kind, sectionControls } = row as Record<string, unknown>;\n if (typeof slug !== \"string\" || !slug || (PACKAGE_SLUGS.has(slug) && !own.has(slug))) return [];\n return [\n {\n slug,\n label: typeof label === \"string\" ? label : slug,\n category: typeof category === \"string\" ? category : \"content\",\n ...(kind === \"hero\" || kind === \"section\" || kind === \"navbar\" ? { kind } : {}),\n ...(sectionControls && typeof sectionControls === \"object\"\n ? { sectionControls: sectionControls as BlockLibraryEntry[\"sectionControls\"] }\n : {}),\n },\n ];\n });\n}\n\n/**\n * The Block library's section controls at request time, for a page route\n * to hand `RenderBlocks` as `sectionControls`. Access is overridden: the\n * Global is read by editors, and the page is read by everyone. A site\n * extra's stored ticks are kept, and one the document does not hold yet\n * takes its catalogue default from the Global's config; pass `extras` only\n * to add entries the config does not know.\n */\nexport async function getSectionControls(\n payload: BlockLibraryReader | Payload,\n extras: readonly BlockLibraryEntry[] = blockLibraryEntriesFromConfig(payload as BlockLibraryReader),\n): Promise<Record<string, SectionControls>> {\n const doc = (await payload.findGlobal({ slug: BLOCK_LIBRARY_SLU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M,EAAE,MAAM,OAAO,UAAU,MAAM,oBAAoB;AACzD,MAAI,OAAO,SAAS,YAAY,CAAC,QAAS,cAAc,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,CAAG,QAAO,EAAE;AAC/F,SAAO,CACL;GACE;GACA,OAAO,OAAO,UAAU,WAAW,QAAQ;GAC3C,UAAU,OAAO,aAAa,WAAW,WAAW;GACpD,GAAI,SAAS,UAAU,SAAS,aAAa,SAAS,WAAW,EAAE,MAAM,GAAG,EAAE;GAC9E,GAAI,mBAAmB,OAAO,oBAAoB,WAC9C,EAAmB,iBAAyD,GAC5E,EAAE;GACP,CACF;GACD;;;;;;;;;;AAWJ,eAAsB,mBACpB,SACA,SAAuC,8BAA8B,QAA8B,EACzD;AAK1C,QAAO,2BAJM,MAAM,QAAQ,WAAW;EAAE,MAAM;EAAoB,OAAO;EAAG,gBAAgB;EAAM,CAAC,EAI5D,OAAO"}
@@ -0,0 +1,32 @@
1
+ //#region src/collections/root-page-key.ts
2
+ /**
3
+ * The home page is the row whose `pageKey` is `/`. That key is the identifier.
4
+ * The stored slug is an internal token so an unaddressed draft can keep an
5
+ * empty slug without colliding with home. Editors see `/`, never the token.
6
+ */
7
+ const ROOT_PAGE_KEY = "/";
8
+ const ROOT_PAGE_SLUG = "__root__";
9
+ const REQUIRED_PAGE_CELL = "@bison-lab/payload-core/admin#RequiredPageCell";
10
+ const REQUIRED_PAGE_FIELD = "@bison-lab/payload-core/admin#RequiredPageField";
11
+ const PAGE_SLUG_CELL = "@bison-lab/payload-core/admin#PageSlugCell";
12
+ const REQUIRED_PAGE_DELETE_MESSAGE = "This page is required by the site and cannot be deleted.";
13
+ const REQUIRED_PAGE_UNPUBLISH_MESSAGE = "This page is required by the site and cannot be unpublished.";
14
+ function isRootPageKey(value) {
15
+ return value === "/";
16
+ }
17
+ function isRequiredPageKey(value, requiredKeys) {
18
+ return typeof value === "string" && requiredKeys.includes(value);
19
+ }
20
+ /** `/` is always required. Extras are site keys, not paths, and cannot be the root token. */
21
+ function requiredPageKeys(extra = []) {
22
+ const keys = ["/"];
23
+ for (const key of extra) {
24
+ if (key === "/" || key === "__root__" || key.trim() === "") throw new Error(`createPages requiredKeys cannot include ${JSON.stringify(key)}. The home page is always "/".`);
25
+ if (!keys.includes(key)) keys.push(key);
26
+ }
27
+ return keys;
28
+ }
29
+ //#endregion
30
+ export { REQUIRED_PAGE_UNPUBLISH_MESSAGE as a, isRequiredPageKey as c, REQUIRED_PAGE_FIELD as i, isRootPageKey as l, REQUIRED_PAGE_CELL as n, ROOT_PAGE_KEY as o, REQUIRED_PAGE_DELETE_MESSAGE as r, ROOT_PAGE_SLUG as s, PAGE_SLUG_CELL as t, requiredPageKeys as u };
31
+
32
+ //# sourceMappingURL=root-page-key-B86JwL8Z.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-page-key-B86JwL8Z.mjs","names":[],"sources":["../src/collections/root-page-key.ts"],"sourcesContent":["/**\n * The home page is the row whose `pageKey` is `/`. That key is the identifier.\n * The stored slug is an internal token so an unaddressed draft can keep an\n * empty slug without colliding with home. Editors see `/`, never the token.\n */\nexport const ROOT_PAGE_KEY = \"/\";\n\nexport const ROOT_PAGE_SLUG = \"__root__\";\n\nexport const REQUIRED_PAGE_CELL =\n \"@bison-lab/payload-core/admin#RequiredPageCell\";\n\nexport const REQUIRED_PAGE_FIELD =\n \"@bison-lab/payload-core/admin#RequiredPageField\";\n\nexport const PAGE_SLUG_CELL = \"@bison-lab/payload-core/admin#PageSlugCell\";\n\nexport const REQUIRED_PAGE_DELETE_MESSAGE =\n \"This page is required by the site and cannot be deleted.\";\n\nexport const REQUIRED_PAGE_UNPUBLISH_MESSAGE =\n \"This page is required by the site and cannot be unpublished.\";\n\nexport function isRootPageKey(value: unknown): value is typeof ROOT_PAGE_KEY {\n return value === ROOT_PAGE_KEY;\n}\n\nexport function isRequiredPageKey(\n value: unknown,\n requiredKeys: readonly string[],\n): boolean {\n return typeof value === \"string\" && requiredKeys.includes(value);\n}\n\n/** `/` is always required. Extras are site keys, not paths, and cannot be the root token. */\nexport function requiredPageKeys(extra: readonly string[] = []): string[] {\n const keys = [ROOT_PAGE_KEY];\n for (const key of extra) {\n if (key === ROOT_PAGE_KEY || key === ROOT_PAGE_SLUG || key.trim() === \"\") {\n throw new Error(\n `createPages requiredKeys cannot include ${JSON.stringify(key)}. The home page is always \"/\".`,\n );\n }\n if (!keys.includes(key)) keys.push(key);\n }\n return keys;\n}\n"],"mappings":";;;;;;AAKA,MAAa,gBAAgB;AAE7B,MAAa,iBAAiB;AAE9B,MAAa,qBACX;AAEF,MAAa,sBACX;AAEF,MAAa,iBAAiB;AAE9B,MAAa,+BACX;AAEF,MAAa,kCACX;AAEF,SAAgB,cAAc,OAA+C;AAC3E,QAAO,UAAA;;AAGT,SAAgB,kBACd,OACA,cACS;AACT,QAAO,OAAO,UAAU,YAAY,aAAa,SAAS,MAAM;;;AAIlE,SAAgB,iBAAiB,QAA2B,EAAE,EAAY;CACxE,MAAM,OAAO,CAAA,IAAe;AAC5B,MAAK,MAAM,OAAO,OAAO;AACvB,MAAI,QAAA,OAAyB,QAAA,cAA0B,IAAI,MAAM,KAAK,GACpE,OAAM,IAAI,MACR,2CAA2C,KAAK,UAAU,IAAI,CAAC,gCAChE;AAEH,MAAI,CAAC,KAAK,SAAS,IAAI,CAAE,MAAK,KAAK,IAAI;;AAEzC,QAAO"}
package/dist/seo.d.mts ADDED
@@ -0,0 +1,216 @@
1
+ import { Payload } from "payload";
2
+ import { ReactElement } from "react";
3
+
4
+ //#region src/seo/sitemap.d.ts
5
+ /**
6
+ * A page as the sitemap needs it; a site's generated `Page` is assignable.
7
+ * Every field is optional and nullable, as `getSitemapPages` selects only
8
+ * these.
9
+ */
10
+ interface SitemapPage {
11
+ slug?: string | null;
12
+ pageKey?: string | null;
13
+ updatedAt?: string | null;
14
+ meta?: {
15
+ noIndex?: boolean | null;
16
+ } | null;
17
+ }
18
+ /**
19
+ * One `<url>` of `/sitemap.xml`. Structurally assignable to an item of Next's
20
+ * `MetadataRoute.Sitemap`, without this package depending on `next`.
21
+ */
22
+ interface SitemapEntry {
23
+ url: string;
24
+ lastModified?: string | Date;
25
+ changeFrequency?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
26
+ priority?: number;
27
+ }
28
+ interface PageSitemapOptions<P extends SitemapPage> {
29
+ /** Public path of a page: the site's own route helper, home included. */
30
+ path: (page: P) => string;
31
+ /** Turns a path into an absolute URL at the site's origin. */
32
+ absoluteUrl: (path: string) => string;
33
+ /** Per-page `changeFrequency` / `priority`; the URL and last edit are set here. */
34
+ entry?: (page: P) => Omit<SitemapEntry, "url" | "lastModified">;
35
+ /**
36
+ * The routes the site still serves from code, as absolute-URL entries.
37
+ * They follow the pages. A route at a URL a page already lists is merged
38
+ * into that page's entry (the page's fields win); a route at the URL of a
39
+ * page hidden from search is dropped, because that page is what serves it.
40
+ */
41
+ routes?: readonly SitemapEntry[];
42
+ }
43
+ /**
44
+ * `/sitemap.xml` from the published pages: every page with an address,
45
+ * skipping those the SEO tab hides from search (`meta.noIndex`), then the
46
+ * site's code-owned routes, one entry per URL. Pass the result straight back
47
+ * from `app/sitemap.ts`.
48
+ */
49
+ declare function pageSitemap<P extends SitemapPage>(pages: readonly P[], {
50
+ path,
51
+ absoluteUrl,
52
+ entry,
53
+ routes
54
+ }: PageSitemapOptions<P>): SitemapEntry[];
55
+ /** The one Local API call the reader makes, for a caller without a `Payload`. */
56
+ interface SitemapPagesReader {
57
+ find: (args: {
58
+ collection: string;
59
+ where: Record<string, unknown>;
60
+ draft: boolean;
61
+ depth: number;
62
+ pagination: boolean;
63
+ select: Record<string, unknown>;
64
+ }) => Promise<{
65
+ docs: unknown[];
66
+ }>;
67
+ }
68
+ interface GetSitemapPagesArgs {
69
+ /** The site's `Payload` (generated slugs and all), or anything with that `find`. */
70
+ payload: SitemapPagesReader | Payload;
71
+ /** The pages collection's slug. Default `pages` (`createPages`). */
72
+ collection?: string;
73
+ }
74
+ /**
75
+ * Every published page, with only the fields `pageSitemap` reads. A draft
76
+ * never reaches the sitemap: the query filters on `_status` and reads the
77
+ * published version. `updatedAt` is the document's, so an autosaved draft
78
+ * over a live page can move a page's `lastModified` before it is republished.
79
+ */
80
+ declare function getSitemapPages({
81
+ payload,
82
+ collection
83
+ }: GetSitemapPagesArgs): Promise<SitemapPage[]>;
84
+ //#endregion
85
+ //#region src/seo/json-ld.d.ts
86
+ declare const SCHEMA_ORG = "https://schema.org";
87
+ /** One schema.org node: a `@type` and whatever properties that type takes. */
88
+ interface JsonLdNode {
89
+ "@context"?: typeof SCHEMA_ORG;
90
+ "@type": string;
91
+ "@id"?: string;
92
+ [property: string]: unknown;
93
+ }
94
+ /**
95
+ * What `JsonLd` and `jsonLdGraph` accept: anything with a `@type`. No index
96
+ * signature, so an interface (payload-blocks' `FaqPageJsonLd`, a site's own
97
+ * `Product`) is accepted as well as a literal; the functions are generic so
98
+ * a literal's extra properties are not refused either.
99
+ */
100
+ interface JsonLdInput {
101
+ "@type": string | readonly string[];
102
+ }
103
+ /** A node, or nothing (a builder with nothing to say returns `null`). */
104
+ type MaybeJsonLd<T extends JsonLdInput = JsonLdInput> = T | null | undefined;
105
+ /** Optional text: empty and null both mean "leave the property off". */
106
+ type Text = string | null | undefined;
107
+ interface OrganizationInput {
108
+ name: string;
109
+ /** The site's home URL. */
110
+ url: string;
111
+ /**
112
+ * A more specific schema.org type (`MedicalOrganization`, `LocalBusiness`).
113
+ * Default `Organization`. Claims beyond the type are the site's to add.
114
+ */
115
+ type?: string;
116
+ /** A stable `@id` (`https://acme.test/#organization`) other nodes can point at. */
117
+ id?: Text;
118
+ /** Absolute URL of the logo. */
119
+ logo?: Text;
120
+ description?: Text;
121
+ telephone?: Text;
122
+ email?: Text;
123
+ /** Absolute URLs of the organization's profiles. Empty entries are dropped. */
124
+ sameAs?: readonly Text[];
125
+ }
126
+ interface OrganizationJsonLd extends JsonLdNode {
127
+ "@context": typeof SCHEMA_ORG;
128
+ name: string;
129
+ url: string;
130
+ logo?: string;
131
+ description?: string;
132
+ telephone?: string;
133
+ email?: string;
134
+ sameAs?: string[];
135
+ }
136
+ /** The site's publisher: one Organization node, empty fields left off. */
137
+ declare function organizationJsonLd(input: OrganizationInput): OrganizationJsonLd;
138
+ interface WebsiteInput {
139
+ name: string;
140
+ /** The site's home URL. */
141
+ url: string;
142
+ id?: Text;
143
+ description?: Text;
144
+ /** BCP 47 language tag, `en-US`. */
145
+ inLanguage?: Text;
146
+ /** The publishing Organization's `@id`. */
147
+ publisher?: Text;
148
+ }
149
+ interface WebsiteJsonLd extends JsonLdNode {
150
+ "@context": typeof SCHEMA_ORG;
151
+ "@type": "WebSite";
152
+ name: string;
153
+ url: string;
154
+ description?: string;
155
+ inLanguage?: string;
156
+ publisher?: {
157
+ "@id": string;
158
+ };
159
+ }
160
+ /** The site itself, pointing at its publisher by `@id`. */
161
+ declare function websiteJsonLd(input: WebsiteInput): WebsiteJsonLd;
162
+ interface BreadcrumbItem {
163
+ name: string;
164
+ /** Absolute URL. Leave it off the current page, the trail's last item. */
165
+ url?: Text;
166
+ }
167
+ interface BreadcrumbListJsonLd extends JsonLdNode {
168
+ "@context": typeof SCHEMA_ORG;
169
+ "@type": "BreadcrumbList";
170
+ itemListElement: Array<{
171
+ "@type": "ListItem";
172
+ position: number;
173
+ name: string;
174
+ item?: string;
175
+ }>;
176
+ }
177
+ /**
178
+ * A page's trail, home first, numbered from 1. `null` for an empty trail, so
179
+ * a page with none renders no script.
180
+ */
181
+ declare function breadcrumbListJsonLd(items: readonly BreadcrumbItem[]): BreadcrumbListJsonLd | null;
182
+ interface JsonLdGraph {
183
+ "@context": typeof SCHEMA_ORG;
184
+ "@graph": JsonLdInput[];
185
+ }
186
+ /**
187
+ * Several nodes under one `@context`, the absent ones dropped. `null` when
188
+ * none is left.
189
+ */
190
+ declare function jsonLdGraph<T extends readonly MaybeJsonLd[]>(...nodes: T): JsonLdGraph | null;
191
+ /**
192
+ * JSON for an inline `<script>`, with `<` escaped so a value holding
193
+ * `</script>` cannot close the tag. The escape is still valid JSON.
194
+ */
195
+ declare function jsonLdHtml(data: unknown): string;
196
+ interface JsonLdProps<T extends JsonLdInput = JsonLdInput> {
197
+ /**
198
+ * A node (any builder here, payload-blocks' `faqPageJsonLd`, or a site's
199
+ * own), a graph, or a list of nodes rendered as one `@graph`. Nothing to
200
+ * say (`null`, or a list of nulls) renders nothing.
201
+ */
202
+ data: MaybeJsonLd<T> | JsonLdGraph | readonly MaybeJsonLd<T>[];
203
+ /** CSP nonce for the `<script>` tag. */
204
+ nonce?: string;
205
+ }
206
+ /**
207
+ * One `<script type="application/ld+json">`. A Server Component: no client
208
+ * boundary, no `"use client"`, so a page route renders it as it is.
209
+ */
210
+ declare function JsonLd<T extends JsonLdInput>({
211
+ data,
212
+ nonce
213
+ }: JsonLdProps<T>): ReactElement | null;
214
+ //#endregion
215
+ export { type BreadcrumbItem, type BreadcrumbListJsonLd, type GetSitemapPagesArgs, JsonLd, type JsonLdGraph, type JsonLdInput, type JsonLdNode, type JsonLdProps, type MaybeJsonLd, type OrganizationInput, type OrganizationJsonLd, type PageSitemapOptions, type SitemapEntry, type SitemapPage, type SitemapPagesReader, type WebsiteInput, type WebsiteJsonLd, breadcrumbListJsonLd, getSitemapPages, jsonLdGraph, jsonLdHtml, organizationJsonLd, pageSitemap, websiteJsonLd };
216
+ //# sourceMappingURL=seo.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seo.d.mts","names":[],"sources":["../src/seo/sitemap.ts","../src/seo/json-ld.ts"],"mappings":";;;;;;;AASA;;UAAiB,WAAA;EACf,IAAA;EACA,OAAA;EACA,SAAA;EACA,IAAA;IAAS,OAAA;EAAA;AAAA;;AAOX;;;UAAiB,YAAA;EACf,GAAA;EACA,YAAA,YAAwB,IAAA;EACxB,eAAA;EACA,QAAA;AAAA;AAAA,UAGe,kBAAA,WAA6B,WAAA;EAHpC;EAKR,IAAA,GAAO,IAAA,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155 @@
1
+ import { l as isRootPageKey } from "./root-page-key-B86JwL8Z.mjs";
2
+ import { createElement } from "react";
3
+ //#region src/seo/sitemap.ts
4
+ /** A page with no address yet has nothing to list. Home is keyed, not slugged. */
5
+ function hasAddress(page) {
6
+ return isRootPageKey(page.pageKey) || Boolean(page.slug);
7
+ }
8
+ /**
9
+ * `/sitemap.xml` from the published pages: every page with an address,
10
+ * skipping those the SEO tab hides from search (`meta.noIndex`), then the
11
+ * site's code-owned routes, one entry per URL. Pass the result straight back
12
+ * from `app/sitemap.ts`.
13
+ */
14
+ function pageSitemap(pages, { path, absoluteUrl, entry, routes = [] }) {
15
+ const byUrl = /* @__PURE__ */ new Map();
16
+ const hidden = /* @__PURE__ */ new Set();
17
+ for (const page of pages) {
18
+ if (!hasAddress(page)) continue;
19
+ const url = absoluteUrl(path(page));
20
+ if (page.meta?.noIndex) {
21
+ hidden.add(url);
22
+ continue;
23
+ }
24
+ if (byUrl.has(url)) continue;
25
+ byUrl.set(url, {
26
+ url,
27
+ ...page.updatedAt ? { lastModified: page.updatedAt } : {},
28
+ ...entry?.(page)
29
+ });
30
+ }
31
+ const seenRoutes = /* @__PURE__ */ new Set();
32
+ for (const route of routes) {
33
+ if (hidden.has(route.url) || seenRoutes.has(route.url)) continue;
34
+ seenRoutes.add(route.url);
35
+ const page = byUrl.get(route.url);
36
+ byUrl.set(route.url, page ? {
37
+ ...route,
38
+ ...page
39
+ } : route);
40
+ }
41
+ return [...byUrl.values()];
42
+ }
43
+ /**
44
+ * Every published page, with only the fields `pageSitemap` reads. A draft
45
+ * never reaches the sitemap: the query filters on `_status` and reads the
46
+ * published version. `updatedAt` is the document's, so an autosaved draft
47
+ * over a live page can move a page's `lastModified` before it is republished.
48
+ */
49
+ async function getSitemapPages({ payload, collection = "pages" }) {
50
+ const { docs } = await payload.find({
51
+ collection,
52
+ where: { _status: { equals: "published" } },
53
+ draft: false,
54
+ depth: 0,
55
+ pagination: false,
56
+ select: {
57
+ slug: true,
58
+ pageKey: true,
59
+ updatedAt: true,
60
+ meta: { noIndex: true }
61
+ }
62
+ });
63
+ return docs;
64
+ }
65
+ //#endregion
66
+ //#region src/seo/json-ld.ts
67
+ const SCHEMA_ORG = "https://schema.org";
68
+ function present(key, value) {
69
+ return value ? { [key]: value } : {};
70
+ }
71
+ /** The site's publisher: one Organization node, empty fields left off. */
72
+ function organizationJsonLd(input) {
73
+ const sameAs = (input.sameAs ?? []).filter((url) => Boolean(url));
74
+ return {
75
+ "@context": SCHEMA_ORG,
76
+ "@type": input.type ?? "Organization",
77
+ ...present("@id", input.id),
78
+ name: input.name,
79
+ url: input.url,
80
+ ...present("logo", input.logo),
81
+ ...present("description", input.description),
82
+ ...present("telephone", input.telephone),
83
+ ...present("email", input.email),
84
+ ...sameAs.length > 0 ? { sameAs } : {}
85
+ };
86
+ }
87
+ /** The site itself, pointing at its publisher by `@id`. */
88
+ function websiteJsonLd(input) {
89
+ return {
90
+ "@context": SCHEMA_ORG,
91
+ "@type": "WebSite",
92
+ ...present("@id", input.id),
93
+ name: input.name,
94
+ url: input.url,
95
+ ...present("description", input.description),
96
+ ...present("inLanguage", input.inLanguage),
97
+ ...input.publisher ? { publisher: { "@id": input.publisher } } : {}
98
+ };
99
+ }
100
+ /**
101
+ * A page's trail, home first, numbered from 1. `null` for an empty trail, so
102
+ * a page with none renders no script.
103
+ */
104
+ function breadcrumbListJsonLd(items) {
105
+ if (items.length === 0) return null;
106
+ return {
107
+ "@context": SCHEMA_ORG,
108
+ "@type": "BreadcrumbList",
109
+ itemListElement: items.map((crumb, index) => ({
110
+ "@type": "ListItem",
111
+ position: index + 1,
112
+ name: crumb.name,
113
+ ...present("item", crumb.url)
114
+ }))
115
+ };
116
+ }
117
+ /**
118
+ * Several nodes under one `@context`, the absent ones dropped. `null` when
119
+ * none is left.
120
+ */
121
+ function jsonLdGraph(...nodes) {
122
+ const graph = nodes.flatMap((node) => {
123
+ if (!node) return [];
124
+ const { "@context": _context, ...rest } = node;
125
+ return [rest];
126
+ });
127
+ return graph.length > 0 ? {
128
+ "@context": SCHEMA_ORG,
129
+ "@graph": graph
130
+ } : null;
131
+ }
132
+ /**
133
+ * JSON for an inline `<script>`, with `<` escaped so a value holding
134
+ * `<\/script>` cannot close the tag. The escape is still valid JSON.
135
+ */
136
+ function jsonLdHtml(data) {
137
+ return JSON.stringify(data).replace(/</g, "\\u003c");
138
+ }
139
+ /**
140
+ * One `<script type="application/ld+json">`. A Server Component: no client
141
+ * boundary, no `"use client"`, so a page route renders it as it is.
142
+ */
143
+ function JsonLd({ data, nonce }) {
144
+ const value = Array.isArray(data) ? jsonLdGraph(...data) : data;
145
+ if (!value) return null;
146
+ return createElement("script", {
147
+ type: "application/ld+json",
148
+ nonce,
149
+ dangerouslySetInnerHTML: { __html: jsonLdHtml(value) }
150
+ });
151
+ }
152
+ //#endregion
153
+ export { JsonLd, breadcrumbListJsonLd, getSitemapPages, jsonLdGraph, jsonLdHtml, organizationJsonLd, pageSitemap, websiteJsonLd };
154
+
155
+ //# sourceMappingURL=seo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seo.mjs","names":[],"sources":["../src/seo/sitemap.ts","../src/seo/json-ld.ts"],"sourcesContent":["import type { Payload } from \"payload\";\n\nimport { isRootPageKey } from \"../collections/root-page-key\";\n\n/**\n * A page as the sitemap needs it; a site's generated `Page` is assignable.\n * Every field is optional and nullable, as `getSitemapPages` selects only\n * these.\n */\nexport interface SitemapPage {\n slug?: string | null;\n pageKey?: string | null;\n updatedAt?: string | null;\n meta?: { noIndex?: boolean | null } | null;\n}\n\n/**\n * One `<url>` of `/sitemap.xml`. Structurally assignable to an item of Next's\n * `MetadataRoute.Sitemap`, without this package depending on `next`.\n */\nexport interface SitemapEntry {\n url: string;\n lastModified?: string | Date;\n changeFrequency?: \"always\" | \"hourly\" | \"daily\" | \"weekly\" | \"monthly\" | \"yearly\" | \"never\";\n priority?: number;\n}\n\nexport interface PageSitemapOptions<P extends SitemapPage> {\n /** Public path of a page: the site's own route helper, home included. */\n path: (page: P) => string;\n /** Turns a path into an absolute URL at the site's origin. */\n absoluteUrl: (path: string) => string;\n /** Per-page `changeFrequency` / `priority`; the URL and last edit are set here. */\n entry?: (page: P) => Omit<SitemapEntry, \"url\" | \"lastModified\">;\n /**\n * The routes the site still serves from code, as absolute-URL entries.\n * They follow the pages. A route at a URL a page already lists is merged\n * into that page's entry (the page's fields win); a route at the URL of a\n * page hidden from search is dropped, because that page is what serves it.\n */\n routes?: readonly SitemapEntry[];\n}\n\n/** A page with no address yet has nothing to list. Home is keyed, not slugged. */\nfunction hasAddress(page: SitemapPage): boolean {\n return isRootPageKey(page.pageKey) || Boolean(page.slug);\n}\n\n/**\n * `/sitemap.xml` from the published pages: every page with an address,\n * skipping those the SEO tab hides from search (`meta.noIndex`), then the\n * site's code-owned routes, one entry per URL. Pass the result straight back\n * from `app/sitemap.ts`.\n */\nexport function pageSitemap<P extends SitemapPage>(\n pages: readonly P[],\n { path, absoluteUrl, entry, routes = [] }: PageSitemapOptions<P>,\n): SitemapEntry[] {\n const byUrl = new Map<string, SitemapEntry>();\n const hidden = new Set<string>();\n\n for (const page of pages) {\n if (!hasAddress(page)) continue;\n const url = absoluteUrl(path(page));\n if (page.meta?.noIndex) {\n hidden.add(url);\n continue;\n }\n if (byUrl.has(url)) continue;\n byUrl.set(url, {\n url,\n ...(page.updatedAt ? { lastModified: page.updatedAt } : {}),\n ...entry?.(page),\n });\n }\n\n const seenRoutes = new Set<string>();\n for (const route of routes) {\n // The first route at a URL wins over a later duplicate.\n if (hidden.has(route.url) || seenRoutes.has(route.url)) continue;\n seenRoutes.add(route.url);\n const page = byUrl.get(route.url);\n byUrl.set(route.url, page ? { ...route, ...page } : route);\n }\n\n return [...byUrl.values()];\n}\n\n/** The one Local API call the reader makes, for a caller without a `Payload`. */\nexport interface SitemapPagesReader {\n find: (args: {\n collection: string;\n where: Record<string, unknown>;\n draft: boolean;\n depth: number;\n pagination: boolean;\n select: Record<string, unknown>;\n }) => Promise<{ docs: unknown[] }>;\n}\n\nexport interface GetSitemapPagesArgs {\n /** The site's `Payload` (generated slugs and all), or anything with that `find`. */\n payload: SitemapPagesReader | Payload;\n /** The pages collection's slug. Default `pages` (`createPages`). */\n collection?: string;\n}\n\n/**\n * Every published page, with only the fields `pageSitemap` reads. A draft\n * never reaches the sitemap: the query filters on `_status` and reads the\n * published version. `updatedAt` is the document's, so an autosaved draft\n * over a live page can move a page's `lastModified` before it is republished.\n */\nexport async function getSitemapPages({\n payload,\n collection = \"pages\",\n}: GetSitemapPagesArgs): Promise<SitemapPage[]> {\n const { docs } = await (payload as SitemapPagesReader).find({\n collection,\n where: { _status: { equals: \"published\" } },\n draft: false,\n depth: 0,\n pagination: false,\n select: { slug: true, pageKey: true, updatedAt: true, meta: { noIndex: true } },\n });\n return docs as SitemapPage[];\n}\n","import { createElement, type ReactElement } from \"react\";\n\nconst SCHEMA_ORG = \"https://schema.org\";\n\n/** One schema.org node: a `@type` and whatever properties that type takes. */\nexport interface JsonLdNode {\n \"@context\"?: typeof SCHEMA_ORG;\n \"@type\": string;\n \"@id\"?: string;\n [property: string]: unknown;\n}\n\n/**\n * What `JsonLd` and `jsonLdGraph` accept: anything with a `@type`. No index\n * signature, so an interface (payload-blocks' `FaqPageJsonLd`, a site's own\n * `Product`) is accepted as well as a literal; the functions are generic so\n * a literal's extra properties are not refused either.\n */\nexport interface JsonLdInput {\n \"@type\": string | readonly string[];\n}\n\n/** A node, or nothing (a builder with nothing to say returns `null`). */\nexport type MaybeJsonLd<T extends JsonLdInput = JsonLdInput> = T | null | undefined;\n\n/** Optional text: empty and null both mean \"leave the property off\". */\ntype Text = string | null | undefined;\n\nfunction present<K extends string>(key: K, value: Text): Partial<Record<K, string>> {\n return value ? ({ [key]: value } as Record<K, string>) : {};\n}\n\nexport interface OrganizationInput {\n name: string;\n /** The site's home URL. */\n url: string;\n /**\n * A more specific schema.org type (`MedicalOrganization`, `LocalBusiness`).\n * Default `Organization`. Claims beyond the type are the site's to add.\n */\n type?: string;\n /** A stable `@id` (`https://acme.test/#organization`) other nodes can point at. */\n id?: Text;\n /** Absolute URL of the logo. */\n logo?: Text;\n description?: Text;\n telephone?: Text;\n email?: Text;\n /** Absolute URLs of the organization's profiles. Empty entries are dropped. */\n sameAs?: readonly Text[];\n}\n\nexport interface OrganizationJsonLd extends JsonLdNode {\n \"@context\": typeof SCHEMA_ORG;\n name: string;\n url: string;\n logo?: string;\n description?: string;\n telephone?: string;\n email?: string;\n sameAs?: string[];\n}\n\n/** The site's publisher: one Organization node, empty fields left off. */\nexport function organizationJsonLd(input: OrganizationInput): OrganizationJsonLd {\n const sameAs = (input.sameAs ?? []).filter((url): url is string => Boolean(url));\n return {\n \"@context\": SCHEMA_ORG,\n \"@type\": input.type ?? \"Organization\",\n ...present(\"@id\", input.id),\n name: input.name,\n url: input.url,\n ...present(\"logo\", input.logo),\n ...present(\"description\", input.description),\n ...present(\"telephone\", input.telephone),\n ...present(\"email\", input.email),\n ...(sameAs.length > 0 ? { sameAs } : {}),\n };\n}\n\nexport interface WebsiteInput {\n name: string;\n /** The site's home URL. */\n url: string;\n id?: Text;\n description?: Text;\n /** BCP 47 language tag, `en-US`. */\n inLanguage?: Text;\n /** The publishing Organization's `@id`. */\n publisher?: Text;\n}\n\nexport interface WebsiteJsonLd extends JsonLdNode {\n \"@context\": typeof SCHEMA_ORG;\n \"@type\": \"WebSite\";\n name: string;\n url: string;\n description?: string;\n inLanguage?: string;\n publisher?: { \"@id\": string };\n}\n\n/** The site itself, pointing at its publisher by `@id`. */\nexport function websiteJsonLd(input: WebsiteInput): WebsiteJsonLd {\n return {\n \"@context\": SCHEMA_ORG,\n \"@type\": \"WebSite\",\n ...present(\"@id\", input.id),\n name: input.name,\n url: input.url,\n ...present(\"description\", input.description),\n ...present(\"inLanguage\", input.inLanguage),\n ...(input.publisher ? { publisher: { \"@id\": input.publisher } } : {}),\n };\n}\n\nexport interface BreadcrumbItem {\n name: string;\n /** Absolute URL. Leave it off the current page, the trail's last item. */\n url?: Text;\n}\n\nexport interface BreadcrumbListJsonLd extends JsonLdNode {\n \"@context\": typeof SCHEMA_ORG;\n \"@type\": \"BreadcrumbList\";\n itemListElement: Array<{ \"@type\": \"ListItem\"; position: number; name: string; item?: string }>;\n}\n\n/**\n * A page's trail, home first, numbered from 1. `null` for an empty trail, so\n * a page with none renders no script.\n */\nexport function breadcrumbListJsonLd(items: readonly BreadcrumbItem[]): BreadcrumbListJsonLd | null {\n if (items.length === 0) return null;\n return {\n \"@context\": SCHEMA_ORG,\n \"@type\": \"BreadcrumbList\",\n itemListElement: items.map((crumb, index) => ({\n \"@type\": \"ListItem\" as const,\n position: index + 1,\n name: crumb.name,\n ...present(\"item\", crumb.url),\n })),\n };\n}\n\nexport interface JsonLdGraph {\n \"@context\": typeof SCHEMA_ORG;\n \"@graph\": JsonLdInput[];\n}\n\n/**\n * Several nodes under one `@context`, the absent ones dropped. `null` when\n * none is left.\n */\nexport function jsonLdGraph<T extends readonly MaybeJsonLd[]>(...nodes: T): JsonLdGraph | null {\n const graph = nodes.flatMap((node) => {\n if (!node) return [];\n const { \"@context\": _context, ...rest } = node as JsonLdInput & { \"@context\"?: unknown };\n return [rest as JsonLdInput];\n });\n return graph.length > 0 ? { \"@context\": SCHEMA_ORG, \"@graph\": graph } : null;\n}\n\n/**\n * JSON for an inline `<script>`, with `<` escaped so a value holding\n * `</script>` cannot close the tag. The escape is still valid JSON.\n */\nexport function jsonLdHtml(data: unknown): string {\n return JSON.stringify(data).replace(/</g, \"\\\\u003c\");\n}\n\nexport interface JsonLdProps<T extends JsonLdInput = JsonLdInput> {\n /**\n * A node (any builder here, payload-blocks' `faqPageJsonLd`, or a site's\n * own), a graph, or a list of nodes rendered as one `@graph`. Nothing to\n * say (`null`, or a list of nulls) renders nothing.\n */\n data: MaybeJsonLd<T> | JsonLdGraph | readonly MaybeJsonLd<T>[];\n /** CSP nonce for the `<script>` tag. */\n nonce?: string;\n}\n\n/**\n * One `<script type=\"application/ld+json\">`. A Server Component: no client\n * boundary, no `\"use client\"`, so a page route renders it as it is.\n */\nexport function JsonLd<T extends JsonLdInput>({ data, nonce }: JsonLdProps<T>): ReactElement | null {\n const value = Array.isArray(data) ? jsonLdGraph(...(data as readonly MaybeJsonLd[])) : data;\n if (!value) return null;\n return createElement(\"script\", {\n type: \"application/ld+json\",\n nonce,\n dangerouslySetInnerHTML: { __html: jsonLdHtml(value) },\n });\n}\n"],"mappings":";;;;AA4CA,SAAS,WAAW,MAA4B;AAC9C,QAAO,cAAc,KAAK,QAAQ,IAAI,QAAQ,KAAK,KAAK;;;;;;;;AAS1D,SAAgB,YACd,OACA,EAAE,MAAM,aAAa,OAAO,SAAS,EAAE,IACvB;CAChB,MAAM,wBAAQ,IAAI,KAA2B;CAC7C,MAAM,yBAAS,IAAI,KAAa;AAEhC,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,CAAC,WAAW,KAAK,CAAE;EACvB,MAAM,MAAM,YAAY,KAAK,KAAK,CAAC;AACnC,MAAI,KAAK,MAAM,SAAS;AACtB,UAAO,IAAI,IAAI;AACf;;AAEF,MAAI,MAAM,IAAI,IAAI,CAAE;AACpB,QAAM,IAAI,KAAK;GACb;GACA,GAAI,KAAK,YAAY,EAAE,cAAc,KAAK,WAAW,GAAG,EAAE;GAC1D,GAAG,QAAQ,KAAK;GACjB,CAAC;;CAGJ,MAAM,6BAAa,IAAI,KAAa;AACpC,MAAK,MAAM,SAAS,QAAQ;AAE1B,MAAI,OAAO,IAAI,MAAM,IAAI,IAAI,WAAW,IAAI,MAAM,IAAI,CAAE;AACxD,aAAW,IAAI,MAAM,IAAI;EACzB,MAAM,OAAO,MAAM,IAAI,MAAM,IAAI;AACjC,QAAM,IAAI,MAAM,KAAK,OAAO;GAAE,GAAG;GAAO,GAAG;GAAM,GAAG,MAAM;;AAG5D,QAAO,CAAC,GAAG,MAAM,QAAQ,CAAC;;;;;;;;AA4B5B,eAAsB,gBAAgB,EACpC,SACA,aAAa,WAC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,OAAO,WAAW;GAC5C,SAAS;GACT,UAAU,QAAQ;GAClB,MAAM,MAAM;GACZ,GAAG,QAAQ,QAAQ,MAAM,IAAI;GAC9B,EAAE;EACJ;;;;;;AAYH,SAAgB,YAA8C,GAAG,OAA8B;CAC7F,MAAM,QAAQ,MAAM,SAAS,SAAS;AACpC,MAAI,CAAC,KAAM,QAAO,EAAE;EACpB,MAAM,EAAE,YAAY,UAAU,GAAG,SAAS;AAC1C,SAAO,CAAC,KAAoB;GAC5B;AACF,QAAO,MAAM,SAAS,IAAI;EAAE,YAAY;EAAY,UAAU;EAAO,GAAG;;;;;;AAO1E,SAAgB,WAAW,MAAuB;AAChD,QAAO,KAAK,UAAU,KAAK,CAAC,QAAQ,MAAM,UAAU;;;;;;AAkBtD,SAAgB,OAA8B,EAAE,MAAM,SAA8C;CAClG,MAAM,QAAQ,MAAM,QAAQ,KAAK,GAAG,YAAY,GAAI,KAAgC,GAAG;AACvF,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,cAAc,UAAU;EAC7B,MAAM;EACN;EACA,yBAAyB,EAAE,QAAQ,WAAW,MAAM,EAAE;EACvD,CAAC"}
@@ -0,0 +1,19 @@
1
+ //#region src/seo/share-image.ts
2
+ /**
3
+ * The rendition a media collection cuts for social share cards: 1.91:1 at the
4
+ * size Open Graph consumers ask for, cropped to shape rather than letterboxed
5
+ * so a portrait upload still fills the card. Add it to the upload
6
+ * collection's `imageSizes`; `pageMetadata` reads `sizes.share` off a page's
7
+ * meta image and falls back to the original for a file uploaded before the
8
+ * size existed, or one too small to cut (Payload does not upscale).
9
+ */
10
+ const SHARE_IMAGE_SIZE = {
11
+ name: "share",
12
+ width: 1200,
13
+ height: 630,
14
+ position: "centre"
15
+ };
16
+ //#endregion
17
+ export { SHARE_IMAGE_SIZE as t };
18
+
19
+ //# sourceMappingURL=share-image-C8ZtIcU8.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-image-C8ZtIcU8.mjs","names":[],"sources":["../src/seo/share-image.ts"],"sourcesContent":["import type { ImageSize } from \"payload\";\n\n/**\n * The rendition a media collection cuts for social share cards: 1.91:1 at the\n * size Open Graph consumers ask for, cropped to shape rather than letterboxed\n * so a portrait upload still fills the card. Add it to the upload\n * collection's `imageSizes`; `pageMetadata` reads `sizes.share` off a page's\n * meta image and falls back to the original for a file uploaded before the\n * size existed, or one too small to cut (Payload does not upscale).\n */\nexport const SHARE_IMAGE_SIZE = {\n name: \"share\",\n width: 1200,\n height: 630,\n position: \"centre\",\n} satisfies ImageSize;\n"],"mappings":";;;;;;;;;AAUA,MAAa,mBAAmB;CAC9B,MAAM;CACN,OAAO;CACP,QAAQ;CACR,UAAU;CACX"}
@@ -1,2 +1,2 @@
1
- import { n as facetField, t as FacetEntry } from "./facet-field-DKzRCYrh.mjs";
1
+ import { n as facetField, t as FacetEntry } from "./facet-field-BvQp8Hzh.mjs";
2
2
  export { type FacetEntry, facetField };
package/dist/taxonomy.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as facetField } from "./facet-field-Di1kNyzH.mjs";
1
+ import { t as facetField } from "./facet-field-Uf8S4yL1.mjs";
2
2
  export { facetField };