@nocode-factory/sanity-kit 2.48.0 → 2.48.1
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +2 -1
- package/dist/schema.js.map +1 -1
- package/package.json +1 -1
- package/src/schema/formTabs.ts +4 -2
- package/src/version.ts +1 -1
package/dist/schema.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { ListItemBuilder, StructureBuilder } from "sanity/structure";
|
|
|
10
10
|
* document va dans son onglet d'après son nom ; « Content » s'ouvre par défaut.
|
|
11
11
|
* - Sections : le champ du page builder (`pageBuilderField`, défaut `sections`,
|
|
12
12
|
* comme l'option du même nom de ncfKit).
|
|
13
|
-
* - SEO : `seo`, `structuredData` et les champs de métadonnées connus.
|
|
13
|
+
* - SEO : `seo`, `structuredData`, `jsonLd` et les champs de métadonnées connus.
|
|
14
14
|
* - Settings : réglages de page (`pageOptions`, `options`, `settings`...).
|
|
15
15
|
* - Content : tout le reste (titre, slug, corps, image...).
|
|
16
16
|
* Un type qui déclare déjà ses `groups` n'est pas touché ; un champ qui a déjà son
|
package/dist/schema.js
CHANGED
|
@@ -8,7 +8,7 @@ import { a as componentDefaultsMainDocument, c as defineComponentDefaults, d as
|
|
|
8
8
|
* document va dans son onglet d'après son nom ; « Content » s'ouvre par défaut.
|
|
9
9
|
* - Sections : le champ du page builder (`pageBuilderField`, défaut `sections`,
|
|
10
10
|
* comme l'option du même nom de ncfKit).
|
|
11
|
-
* - SEO : `seo`, `structuredData` et les champs de métadonnées connus.
|
|
11
|
+
* - SEO : `seo`, `structuredData`, `jsonLd` et les champs de métadonnées connus.
|
|
12
12
|
* - Settings : réglages de page (`pageOptions`, `options`, `settings`...).
|
|
13
13
|
* - Content : tout le reste (titre, slug, corps, image...).
|
|
14
14
|
* Un type qui déclare déjà ses `groups` n'est pas touché ; un champ qui a déjà son
|
|
@@ -22,6 +22,7 @@ const SEO_FIELDS = /* @__PURE__ */ new Set([
|
|
|
22
22
|
"seo",
|
|
23
23
|
"structuredData",
|
|
24
24
|
"jsonld",
|
|
25
|
+
"jsonLd",
|
|
25
26
|
"noindex",
|
|
26
27
|
"metaTitle",
|
|
27
28
|
"metaDescription",
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema/formTabs.ts","../src/schema/redirects.ts"],"sourcesContent":["/**\n * Onglets du formulaire d'un document : Content, Sections, SEO, Settings.\n *\n * Un formulaire de page en une seule colonne mélange le contenu, le page builder et\n * les réglages SEO : on cherche, on se trompe de champ. Ici, chaque champ d'un\n * document va dans son onglet d'après son nom ; « Content » s'ouvre par défaut.\n * - Sections : le champ du page builder (`pageBuilderField`, défaut `sections`,\n * comme l'option du même nom de ncfKit).\n * - SEO : `seo`, `structuredData` et les champs de métadonnées connus.\n * - Settings : réglages de page (`pageOptions`, `options`, `settings`...).\n * - Content : tout le reste (titre, slug, corps, image...).\n * Un type qui déclare déjà ses `groups` n'est pas touché ; un champ qui a déjà son\n * `group` le garde. Pas d'onglets pour un document qui n'aurait qu'un onglet.\n *\n * ```ts\n * schema: {types: withNcfFormTabs(schemaTypes, {pageBuilderField: 'pageBuilder'})}\n * ```\n */\n\nimport {DEFAULT_PAGE_BUILDER_FIELD} from '../config/defaults'\n\nconst SEO_FIELDS = new Set(['seo', 'structuredData', 'jsonld', 'noindex', 'metaTitle', 'metaDescription', 'ogImage', 'canonical', 'canonicalUrl'])\nconst SETTINGS_FIELDS = new Set(['pageOptions', 'options', 'settings', 'hideFromMenu', 'showInMenu', 'parent', 'publishedAt', 'redirects'])\n\nconst GROUPS = [\n {name: 'content', title: 'Content', default: true},\n {name: 'sections', title: 'Sections'},\n {name: 'seo', title: 'SEO'},\n {name: 'settings', title: 'Settings'},\n] as const\n\ntype Field = {name?: string; group?: unknown; hidden?: unknown}\ntype TypeLike = {type?: string; groups?: unknown; fields?: Field[]}\n\n/** Onglet d'un champ d'après son nom. */\nexport function formTabOf(name: string, pageBuilderField = DEFAULT_PAGE_BUILDER_FIELD): (typeof GROUPS)[number]['name'] {\n if (name === pageBuilderField) return 'sections'\n if (SEO_FIELDS.has(name)) return 'seo'\n if (SETTINGS_FIELDS.has(name)) return 'settings'\n return 'content'\n}\n\nexport function withNcfFormTabs<T>(types: readonly T[], options: {pageBuilderField?: string} = {}): T[] {\n return types.map((input) => {\n const type = input as unknown as TypeLike\n if (type.type !== 'document' || type.groups || !Array.isArray(type.fields)) return input\n // Champ toujours caché (hidden: true) : pas d'onglet (il n'en ferait naître un vide).\n const fields = type.fields.map((field) =>\n field.group || !field.name || field.hidden === true ? field : {...field, group: formTabOf(field.name, options.pageBuilderField)},\n )\n const used = new Set(fields.map((f) => f.group).flat())\n const groups = GROUPS.filter((g) => used.has(g.name)).map((g) => ({...g}))\n if (groups.length < 2) return input\n if (!groups.some((g) => 'default' in g && g.default)) (groups[0] as {default?: boolean}).default = true\n return {...type, groups, fields} as unknown as T\n })\n}\n","import type {ComponentType} from 'react'\nimport type {SanityClient} from 'sanity'\nimport type {StructureBuilder, ListItemBuilder} from 'sanity/structure'\nimport {redirectKey, redirectMapOf, followRedirects} from '../lib/finalUrl'\nimport {toPath} from '../lib/paths'\nimport {pageTypesFromSiteRoutes, type SiteRoutesRegistry} from '../lib/siteRoutes'\n\n/**\n * RÈGLES DES REDIRECTIONS (embarquées par le kit, mêmes dans tous les projets) :\n *\n * 1. Trois familles, rangées chacune dans son sous-dossier du Studio (« Redirects ») :\n * - manuelles : saisies par l'équipe ;\n * - changements de slug : créées à la publication d'un nouveau slug\n * (identifiant `redirect-auto-…`) ;\n * - langues : adresse « slug d'origine » d'une version traduite vers son slug\n * traduit (identifiant `redirect-translation-…`, syncTranslationRedirects).\n * La famille vient de l'identifiant : rien à migrer, rien à saisir.\n *\n * 2. Une redirection EN CONFLIT ne peut pas être publiée (validation, erreur) :\n * - même adresse de départ qu'une autre redirection ;\n * - départ = adresse d'une page en ligne (elle deviendrait inaccessible) ;\n * - destination = départ d'une autre redirection (chaîne : viser l'adresse finale) ;\n * - boucle (la destination ramène au départ) ;\n * - destination identique au départ.\n */\n\nexport type RedirectKind = 'manual' | 'slug' | 'translation'\n\nexport const TRANSLATION_REDIRECT_PREFIX = 'redirect-translation-'\nexport const SLUG_REDIRECT_PREFIX = 'redirect-auto-'\n\n/** Famille d'une redirection, d'après son identifiant (brouillon compris). */\nexport function redirectKindOf(id: string | null | undefined): RedirectKind {\n const clean = (id ?? '').replace(/^drafts\\./, '')\n if (clean.startsWith(TRANSLATION_REDIRECT_PREFIX)) return 'translation'\n if (clean.startsWith(SLUG_REDIRECT_PREFIX)) return 'slug'\n return 'manual'\n}\n\nconst idIn = (prefix: string) => `(_id in path(\"${prefix}*\") || _id in path(\"drafts.${prefix}*\"))`\n\n/** Filtre GROQ de chaque famille (à combiner avec `_type == $type`). */\nexport const REDIRECT_KIND_FILTERS: Record<RedirectKind, string> = {\n translation: idIn(TRANSLATION_REDIRECT_PREFIX),\n slug: idIn(SLUG_REDIRECT_PREFIX),\n manual: `!${idIn(TRANSLATION_REDIRECT_PREFIX)} && !${idIn(SLUG_REDIRECT_PREFIX)}`,\n}\n\nexport interface RedirectsStructureOptions {\n /** Type des redirections. Défaut : `redirect`. */\n redirectType?: string\n /** Titre de l'entrée. Défaut : « Redirects ». */\n title?: string\n /** Icône de l'entrée (celle du projet). */\n icon?: ComponentType\n /** Libellés des sous-dossiers (langue du Studio du projet). Défaut : anglais. */\n labels?: Partial<Record<RedirectKind | 'all', string>>\n}\n\nconst DEFAULT_LABELS: Record<RedirectKind | 'all', string> = {\n manual: 'Manual',\n slug: 'Slug changes (automatic)',\n translation: 'Languages (automatic)',\n all: 'All redirects',\n}\n\n/**\n * Entrée « Redirects » du Studio, rangée en sous-dossiers : manuelles (création\n * possible), changements de slug et langues (automatiques), puis toutes.\n * S.list().items([..., redirectsStructure(S, {icon: MyIcon})])\n */\nexport function redirectsStructure(S: StructureBuilder, options: RedirectsStructureOptions = {}): ListItemBuilder {\n const type = options.redirectType ?? 'redirect'\n const title = options.title ?? 'Redirects'\n const labels = {...DEFAULT_LABELS, ...options.labels}\n const list = (kind: RedirectKind, label: string) =>\n S.listItem()\n .id(`redirects-${kind}`)\n .title(label)\n .schemaType(type)\n .child(\n S.documentList()\n .id(`redirects-${kind}-list`)\n .title(label)\n .schemaType(type)\n .apiVersion('2024-10-01')\n .filter(`_type == $type && ${REDIRECT_KIND_FILTERS[kind]}`)\n .params({type})\n .defaultOrdering([{field: 'from', direction: 'asc'}])\n // Création seulement dans les manuelles : les autres sont automatiques.\n .initialValueTemplates(kind === 'manual' ? [S.initialValueTemplateItem(type)] : []),\n )\n const item = S.listItem()\n .id('redirects')\n .title(title)\n .child(\n S.list()\n .id('redirects')\n .title(title)\n .items([\n list('manual', labels.manual),\n list('slug', labels.slug),\n list('translation', labels.translation),\n S.divider(),\n S.listItem().id('redirects-all').title(labels.all).schemaType(type).child(S.documentTypeList(type).title(labels.all)),\n ]),\n )\n return options.icon ? item.icon(options.icon) : item\n}\n\nexport interface RedirectConflictOptions {\n /** Type des redirections. Défaut : `redirect`. */\n redirectType?: string\n /** Registre des pages du site (site-routes.json) : adresses des pages en ligne. */\n siteRoutes?: SiteRoutesRegistry | null\n /** Langues : langue principale (sans préfixe) et champ de langue. */\n i18n?: {defaultLocale: string; field?: string} | null\n /** Champ slug des pages. Défaut : `slug`. */\n slugField?: string\n}\n\ntype Ctx = {document?: {_id?: string; from?: unknown; to?: unknown} | null; getClient: (o: {apiVersion: string}) => SanityClient}\ntype Row = {_id: string; from?: string | null; to?: string | null}\n\nconst clean = (v: unknown) => (typeof v === 'string' ? v.trim() : '')\n\nasync function otherRedirects(ctx: Ctx, type: string): Promise<Row[]> {\n const id = (ctx.document?._id ?? '').replace(/^drafts\\./, '')\n // Publiées et brouillons des AUTRES redirections (le brouillon d'une publiée la remplace).\n const rows = await ctx\n .getClient({apiVersion: '2024-10-01'})\n .withConfig({perspective: 'raw'})\n .fetch<Row[]>(`*[_type == $type && !(_id in [$id, $draft])]{_id, from, to}`, {type, id, draft: `drafts.${id}`})\n const byBase = new Map<string, Row>()\n for (const r of rows) {\n const base = r._id.replace(/^drafts\\./, '')\n if (!byBase.has(base) || r._id.startsWith('drafts.')) byBase.set(base, r)\n }\n return [...byBase.values()]\n}\n\nconst label = (r: Row) => `${clean(r.from)} → ${clean(r.to)}`\n\n/**\n * Validations anti-conflit des champs `from` et `to` d'une redirection (erreurs :\n * la publication est bloquée, avec la raison et la redirection en cause).\n * const conflicts = redirectConflicts({siteRoutes: routes, i18n: {defaultLocale}})\n * defineField({name: 'from', validation: (r) => r.required().custom(conflicts.from)})\n * defineField({name: 'to', validation: (r) => r.required().custom(conflicts.to)})\n */\nexport function redirectConflicts(options: RedirectConflictOptions = {}) {\n const type = options.redirectType ?? 'redirect'\n const field = options.i18n?.field ?? 'language'\n const slugField = options.slugField ?? 'slug'\n const pageTypes = options.siteRoutes ? pageTypesFromSiteRoutes(options.siteRoutes).filter((t) => !t.path) : []\n const i18n = options.i18n ? {field, defaultLocale: options.i18n.defaultLocale, locales: [], defaultsSourceLocale: options.i18n.defaultLocale} : null\n\n // Page en ligne à cette adresse (publiée, dossier et slug de sa langue) ?\n async function pageAt(ctx: Ctx, path: string): Promise<string | null> {\n if (!pageTypes.length) return null\n const key = redirectKey(path)\n const docs = await ctx\n .getClient({apiVersion: '2024-10-01'})\n .withConfig({perspective: 'published'})\n .fetch<{_type: string; title?: string; slug?: string; lang?: string}[]>(\n `*[_type in $types && defined(${slugField}.current)]{_type, title, \"slug\": ${slugField}.current, \"lang\": ${field}}`,\n {types: pageTypes.map((t) => t.type)},\n )\n for (const d of docs) {\n const t = pageTypes.find((p) => p.type === d._type)\n const p = t && toPath({slug: d.slug, pathPrefix: t.pathPrefix, localizedPrefixes: t.localizedPrefixes, locale: d.lang}, i18n)\n if (p && redirectKey(p) === key) return d.title || p\n }\n return null\n }\n\n return {\n async from(value: unknown, context: unknown): Promise<true | string> {\n const ctx = context as Ctx\n const from = clean(value)\n if (!from.startsWith('/')) return true\n const others = await otherRedirects(ctx, type)\n const same = others.find((r) => r.from && redirectKey(r.from) === redirectKey(from))\n if (same) return `Conflict: another redirect already starts from this address (${label(same)}). Edit that one instead.`\n const page = await pageAt(ctx, from)\n if (page) return `Conflict: \"${from}\" is the address of a live page (\"${page}\"). Redirecting it would make that page unreachable.`\n return true\n },\n async to(value: unknown, context: unknown): Promise<true | string> {\n const ctx = context as Ctx\n const to = clean(value)\n const from = clean(ctx.document?.from)\n if (!to.startsWith('/')) return true\n if (from && redirectKey(from) === redirectKey(to)) return 'Conflict: the new address is the same as the old one.'\n const others = await otherRedirects(ctx, type)\n const chained = others.find((r) => r.from && redirectKey(r.from) === redirectKey(to))\n if (chained) {\n const final = followRedirects(to, redirectMapOf(others))\n if (from && redirectKey(final) === redirectKey(from)) return `Conflict: loop. \"${to}\" already redirects back to \"${from}\" (${label(chained)}).`\n return `Conflict: \"${to}\" is itself redirected (${label(chained)}). Point directly to the final address: ${final}`\n }\n return true\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,6BAAa,IAAI,IAAI;CAAC;CAAO;CAAkB;CAAU;CAAW;CAAa;CAAmB;CAAW;CAAa;AAAc,CAAC,GAC3I,kCAAkB,IAAI,IAAI;CAAC;CAAe;CAAW;CAAY;CAAgB;CAAc;CAAU;CAAe;AAAW,CAAC,GAEpI,SAAS;CACb;EAAC,MAAM;EAAW,OAAO;EAAW,SAAS;CAAI;CACjD;EAAC,MAAM;EAAY,OAAO;CAAU;CACpC;EAAC,MAAM;EAAO,OAAO;CAAK;CAC1B;EAAC,MAAM;EAAY,OAAO;CAAU;AACtC;;AAMA,SAAgB,UAAU,MAAc,mBAAmB,4BAA6D;CAItH,OAHI,SAAS,mBAAyB,aAClC,WAAW,IAAI,I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AoB,GAAG,+BAA+B,KAAK,KAAK,MAAM,OAAO,EAAE,MACrI,cAAc,GAAG,0BAA0B,MAAM,OAAO,EAAE,0CAA0C;GAC7G;GACA,OAAO;EACT;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema/formTabs.ts","../src/schema/redirects.ts"],"sourcesContent":["/**\n * Onglets du formulaire d'un document : Content, Sections, SEO, Settings.\n *\n * Un formulaire de page en une seule colonne mélange le contenu, le page builder et\n * les réglages SEO : on cherche, on se trompe de champ. Ici, chaque champ d'un\n * document va dans son onglet d'après son nom ; « Content » s'ouvre par défaut.\n * - Sections : le champ du page builder (`pageBuilderField`, défaut `sections`,\n * comme l'option du même nom de ncfKit).\n * - SEO : `seo`, `structuredData`, `jsonLd` et les champs de métadonnées connus.\n * - Settings : réglages de page (`pageOptions`, `options`, `settings`...).\n * - Content : tout le reste (titre, slug, corps, image...).\n * Un type qui déclare déjà ses `groups` n'est pas touché ; un champ qui a déjà son\n * `group` le garde. Pas d'onglets pour un document qui n'aurait qu'un onglet.\n *\n * ```ts\n * schema: {types: withNcfFormTabs(schemaTypes, {pageBuilderField: 'pageBuilder'})}\n * ```\n */\n\nimport {DEFAULT_PAGE_BUILDER_FIELD} from '../config/defaults'\n\n// `jsonLd` : champ « Données structurées » du kit (defineJsonLdType), avec ses modes\n// auto / manuel et le bouton IA : toujours dans l'onglet SEO.\nconst SEO_FIELDS = new Set(['seo', 'structuredData', 'jsonld', 'jsonLd', 'noindex', 'metaTitle', 'metaDescription', 'ogImage', 'canonical', 'canonicalUrl'])\nconst SETTINGS_FIELDS = new Set(['pageOptions', 'options', 'settings', 'hideFromMenu', 'showInMenu', 'parent', 'publishedAt', 'redirects'])\n\nconst GROUPS = [\n {name: 'content', title: 'Content', default: true},\n {name: 'sections', title: 'Sections'},\n {name: 'seo', title: 'SEO'},\n {name: 'settings', title: 'Settings'},\n] as const\n\ntype Field = {name?: string; group?: unknown; hidden?: unknown}\ntype TypeLike = {type?: string; groups?: unknown; fields?: Field[]}\n\n/** Onglet d'un champ d'après son nom. */\nexport function formTabOf(name: string, pageBuilderField = DEFAULT_PAGE_BUILDER_FIELD): (typeof GROUPS)[number]['name'] {\n if (name === pageBuilderField) return 'sections'\n if (SEO_FIELDS.has(name)) return 'seo'\n if (SETTINGS_FIELDS.has(name)) return 'settings'\n return 'content'\n}\n\nexport function withNcfFormTabs<T>(types: readonly T[], options: {pageBuilderField?: string} = {}): T[] {\n return types.map((input) => {\n const type = input as unknown as TypeLike\n if (type.type !== 'document' || type.groups || !Array.isArray(type.fields)) return input\n // Champ toujours caché (hidden: true) : pas d'onglet (il n'en ferait naître un vide).\n const fields = type.fields.map((field) =>\n field.group || !field.name || field.hidden === true ? field : {...field, group: formTabOf(field.name, options.pageBuilderField)},\n )\n const used = new Set(fields.map((f) => f.group).flat())\n const groups = GROUPS.filter((g) => used.has(g.name)).map((g) => ({...g}))\n if (groups.length < 2) return input\n if (!groups.some((g) => 'default' in g && g.default)) (groups[0] as {default?: boolean}).default = true\n return {...type, groups, fields} as unknown as T\n })\n}\n","import type {ComponentType} from 'react'\nimport type {SanityClient} from 'sanity'\nimport type {StructureBuilder, ListItemBuilder} from 'sanity/structure'\nimport {redirectKey, redirectMapOf, followRedirects} from '../lib/finalUrl'\nimport {toPath} from '../lib/paths'\nimport {pageTypesFromSiteRoutes, type SiteRoutesRegistry} from '../lib/siteRoutes'\n\n/**\n * RÈGLES DES REDIRECTIONS (embarquées par le kit, mêmes dans tous les projets) :\n *\n * 1. Trois familles, rangées chacune dans son sous-dossier du Studio (« Redirects ») :\n * - manuelles : saisies par l'équipe ;\n * - changements de slug : créées à la publication d'un nouveau slug\n * (identifiant `redirect-auto-…`) ;\n * - langues : adresse « slug d'origine » d'une version traduite vers son slug\n * traduit (identifiant `redirect-translation-…`, syncTranslationRedirects).\n * La famille vient de l'identifiant : rien à migrer, rien à saisir.\n *\n * 2. Une redirection EN CONFLIT ne peut pas être publiée (validation, erreur) :\n * - même adresse de départ qu'une autre redirection ;\n * - départ = adresse d'une page en ligne (elle deviendrait inaccessible) ;\n * - destination = départ d'une autre redirection (chaîne : viser l'adresse finale) ;\n * - boucle (la destination ramène au départ) ;\n * - destination identique au départ.\n */\n\nexport type RedirectKind = 'manual' | 'slug' | 'translation'\n\nexport const TRANSLATION_REDIRECT_PREFIX = 'redirect-translation-'\nexport const SLUG_REDIRECT_PREFIX = 'redirect-auto-'\n\n/** Famille d'une redirection, d'après son identifiant (brouillon compris). */\nexport function redirectKindOf(id: string | null | undefined): RedirectKind {\n const clean = (id ?? '').replace(/^drafts\\./, '')\n if (clean.startsWith(TRANSLATION_REDIRECT_PREFIX)) return 'translation'\n if (clean.startsWith(SLUG_REDIRECT_PREFIX)) return 'slug'\n return 'manual'\n}\n\nconst idIn = (prefix: string) => `(_id in path(\"${prefix}*\") || _id in path(\"drafts.${prefix}*\"))`\n\n/** Filtre GROQ de chaque famille (à combiner avec `_type == $type`). */\nexport const REDIRECT_KIND_FILTERS: Record<RedirectKind, string> = {\n translation: idIn(TRANSLATION_REDIRECT_PREFIX),\n slug: idIn(SLUG_REDIRECT_PREFIX),\n manual: `!${idIn(TRANSLATION_REDIRECT_PREFIX)} && !${idIn(SLUG_REDIRECT_PREFIX)}`,\n}\n\nexport interface RedirectsStructureOptions {\n /** Type des redirections. Défaut : `redirect`. */\n redirectType?: string\n /** Titre de l'entrée. Défaut : « Redirects ». */\n title?: string\n /** Icône de l'entrée (celle du projet). */\n icon?: ComponentType\n /** Libellés des sous-dossiers (langue du Studio du projet). Défaut : anglais. */\n labels?: Partial<Record<RedirectKind | 'all', string>>\n}\n\nconst DEFAULT_LABELS: Record<RedirectKind | 'all', string> = {\n manual: 'Manual',\n slug: 'Slug changes (automatic)',\n translation: 'Languages (automatic)',\n all: 'All redirects',\n}\n\n/**\n * Entrée « Redirects » du Studio, rangée en sous-dossiers : manuelles (création\n * possible), changements de slug et langues (automatiques), puis toutes.\n * S.list().items([..., redirectsStructure(S, {icon: MyIcon})])\n */\nexport function redirectsStructure(S: StructureBuilder, options: RedirectsStructureOptions = {}): ListItemBuilder {\n const type = options.redirectType ?? 'redirect'\n const title = options.title ?? 'Redirects'\n const labels = {...DEFAULT_LABELS, ...options.labels}\n const list = (kind: RedirectKind, label: string) =>\n S.listItem()\n .id(`redirects-${kind}`)\n .title(label)\n .schemaType(type)\n .child(\n S.documentList()\n .id(`redirects-${kind}-list`)\n .title(label)\n .schemaType(type)\n .apiVersion('2024-10-01')\n .filter(`_type == $type && ${REDIRECT_KIND_FILTERS[kind]}`)\n .params({type})\n .defaultOrdering([{field: 'from', direction: 'asc'}])\n // Création seulement dans les manuelles : les autres sont automatiques.\n .initialValueTemplates(kind === 'manual' ? [S.initialValueTemplateItem(type)] : []),\n )\n const item = S.listItem()\n .id('redirects')\n .title(title)\n .child(\n S.list()\n .id('redirects')\n .title(title)\n .items([\n list('manual', labels.manual),\n list('slug', labels.slug),\n list('translation', labels.translation),\n S.divider(),\n S.listItem().id('redirects-all').title(labels.all).schemaType(type).child(S.documentTypeList(type).title(labels.all)),\n ]),\n )\n return options.icon ? item.icon(options.icon) : item\n}\n\nexport interface RedirectConflictOptions {\n /** Type des redirections. Défaut : `redirect`. */\n redirectType?: string\n /** Registre des pages du site (site-routes.json) : adresses des pages en ligne. */\n siteRoutes?: SiteRoutesRegistry | null\n /** Langues : langue principale (sans préfixe) et champ de langue. */\n i18n?: {defaultLocale: string; field?: string} | null\n /** Champ slug des pages. Défaut : `slug`. */\n slugField?: string\n}\n\ntype Ctx = {document?: {_id?: string; from?: unknown; to?: unknown} | null; getClient: (o: {apiVersion: string}) => SanityClient}\ntype Row = {_id: string; from?: string | null; to?: string | null}\n\nconst clean = (v: unknown) => (typeof v === 'string' ? v.trim() : '')\n\nasync function otherRedirects(ctx: Ctx, type: string): Promise<Row[]> {\n const id = (ctx.document?._id ?? '').replace(/^drafts\\./, '')\n // Publiées et brouillons des AUTRES redirections (le brouillon d'une publiée la remplace).\n const rows = await ctx\n .getClient({apiVersion: '2024-10-01'})\n .withConfig({perspective: 'raw'})\n .fetch<Row[]>(`*[_type == $type && !(_id in [$id, $draft])]{_id, from, to}`, {type, id, draft: `drafts.${id}`})\n const byBase = new Map<string, Row>()\n for (const r of rows) {\n const base = r._id.replace(/^drafts\\./, '')\n if (!byBase.has(base) || r._id.startsWith('drafts.')) byBase.set(base, r)\n }\n return [...byBase.values()]\n}\n\nconst label = (r: Row) => `${clean(r.from)} → ${clean(r.to)}`\n\n/**\n * Validations anti-conflit des champs `from` et `to` d'une redirection (erreurs :\n * la publication est bloquée, avec la raison et la redirection en cause).\n * const conflicts = redirectConflicts({siteRoutes: routes, i18n: {defaultLocale}})\n * defineField({name: 'from', validation: (r) => r.required().custom(conflicts.from)})\n * defineField({name: 'to', validation: (r) => r.required().custom(conflicts.to)})\n */\nexport function redirectConflicts(options: RedirectConflictOptions = {}) {\n const type = options.redirectType ?? 'redirect'\n const field = options.i18n?.field ?? 'language'\n const slugField = options.slugField ?? 'slug'\n const pageTypes = options.siteRoutes ? pageTypesFromSiteRoutes(options.siteRoutes).filter((t) => !t.path) : []\n const i18n = options.i18n ? {field, defaultLocale: options.i18n.defaultLocale, locales: [], defaultsSourceLocale: options.i18n.defaultLocale} : null\n\n // Page en ligne à cette adresse (publiée, dossier et slug de sa langue) ?\n async function pageAt(ctx: Ctx, path: string): Promise<string | null> {\n if (!pageTypes.length) return null\n const key = redirectKey(path)\n const docs = await ctx\n .getClient({apiVersion: '2024-10-01'})\n .withConfig({perspective: 'published'})\n .fetch<{_type: string; title?: string; slug?: string; lang?: string}[]>(\n `*[_type in $types && defined(${slugField}.current)]{_type, title, \"slug\": ${slugField}.current, \"lang\": ${field}}`,\n {types: pageTypes.map((t) => t.type)},\n )\n for (const d of docs) {\n const t = pageTypes.find((p) => p.type === d._type)\n const p = t && toPath({slug: d.slug, pathPrefix: t.pathPrefix, localizedPrefixes: t.localizedPrefixes, locale: d.lang}, i18n)\n if (p && redirectKey(p) === key) return d.title || p\n }\n return null\n }\n\n return {\n async from(value: unknown, context: unknown): Promise<true | string> {\n const ctx = context as Ctx\n const from = clean(value)\n if (!from.startsWith('/')) return true\n const others = await otherRedirects(ctx, type)\n const same = others.find((r) => r.from && redirectKey(r.from) === redirectKey(from))\n if (same) return `Conflict: another redirect already starts from this address (${label(same)}). Edit that one instead.`\n const page = await pageAt(ctx, from)\n if (page) return `Conflict: \"${from}\" is the address of a live page (\"${page}\"). Redirecting it would make that page unreachable.`\n return true\n },\n async to(value: unknown, context: unknown): Promise<true | string> {\n const ctx = context as Ctx\n const to = clean(value)\n const from = clean(ctx.document?.from)\n if (!to.startsWith('/')) return true\n if (from && redirectKey(from) === redirectKey(to)) return 'Conflict: the new address is the same as the old one.'\n const others = await otherRedirects(ctx, type)\n const chained = others.find((r) => r.from && redirectKey(r.from) === redirectKey(to))\n if (chained) {\n const final = followRedirects(to, redirectMapOf(others))\n if (from && redirectKey(final) === redirectKey(from)) return `Conflict: loop. \"${to}\" already redirects back to \"${from}\" (${label(chained)}).`\n return `Conflict: \"${to}\" is itself redirected (${label(chained)}). Point directly to the final address: ${final}`\n }\n return true\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,6BAAa,IAAI,IAAI;CAAC;CAAO;CAAkB;CAAU;CAAU;CAAW;CAAa;CAAmB;CAAW;CAAa;AAAc,CAAC,GACrJ,kCAAkB,IAAI,IAAI;CAAC;CAAe;CAAW;CAAY;CAAgB;CAAc;CAAU;CAAe;AAAW,CAAC,GAEpI,SAAS;CACb;EAAC,MAAM;EAAW,OAAO;EAAW,SAAS;CAAI;CACjD;EAAC,MAAM;EAAY,OAAO;CAAU;CACpC;EAAC,MAAM;EAAO,OAAO;CAAK;CAC1B;EAAC,MAAM;EAAY,OAAO;CAAU;AACtC;;AAMA,SAAgB,UAAU,MAAc,mBAAmB,4BAA6D;CAItH,OAHI,SAAS,mBAAyB,aAClC,WAAW,IAAI,IAAI,IAAU,QAC7B,g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KAAK,KAAK,MAAM,OAAO,EAAE,MACrI,cAAc,GAAG,0BAA0B,MAAM,OAAO,EAAE,0CAA0C;GAC7G;GACA,OAAO;EACT;CACF;AACF"}
|
package/package.json
CHANGED
package/src/schema/formTabs.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* document va dans son onglet d'après son nom ; « Content » s'ouvre par défaut.
|
|
7
7
|
* - Sections : le champ du page builder (`pageBuilderField`, défaut `sections`,
|
|
8
8
|
* comme l'option du même nom de ncfKit).
|
|
9
|
-
* - SEO : `seo`, `structuredData` et les champs de métadonnées connus.
|
|
9
|
+
* - SEO : `seo`, `structuredData`, `jsonLd` et les champs de métadonnées connus.
|
|
10
10
|
* - Settings : réglages de page (`pageOptions`, `options`, `settings`...).
|
|
11
11
|
* - Content : tout le reste (titre, slug, corps, image...).
|
|
12
12
|
* Un type qui déclare déjà ses `groups` n'est pas touché ; un champ qui a déjà son
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
|
|
20
20
|
import {DEFAULT_PAGE_BUILDER_FIELD} from '../config/defaults'
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// `jsonLd` : champ « Données structurées » du kit (defineJsonLdType), avec ses modes
|
|
23
|
+
// auto / manuel et le bouton IA : toujours dans l'onglet SEO.
|
|
24
|
+
const SEO_FIELDS = new Set(['seo', 'structuredData', 'jsonld', 'jsonLd', 'noindex', 'metaTitle', 'metaDescription', 'ogImage', 'canonical', 'canonicalUrl'])
|
|
23
25
|
const SETTINGS_FIELDS = new Set(['pageOptions', 'options', 'settings', 'hideFromMenu', 'showInMenu', 'parent', 'publishedAt', 'redirects'])
|
|
24
26
|
|
|
25
27
|
const GROUPS = [
|
package/src/version.ts
CHANGED