@nocode-factory/sanity-kit 2.44.1 → 2.44.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocode-factory/sanity-kit",
3
- "version": "2.44.1",
3
+ "version": "2.44.2",
4
4
  "description": "Outils Studio de NoCode Factory : Pages (liste + board), Composants, Historique",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -67,12 +67,23 @@ export function ncfMainDocuments(
67
67
  // Dossier traduit par langue (localizedPrefixes) s'il existe.
68
68
  const prefixOf = (t: (typeof slugTypes)[number]) => (locale && t.localizedPrefixes?.[locale] !== undefined ? t.localizedPrefixes[locale] : t.pathPrefix) ?? ''
69
69
  const collections = [...slugTypes].sort((a, b) => prefixOf(b).length - prefixOf(a).length)
70
+ // Types qui partagent un même dossier (ex. Page et Legal page à la racine) : UNE
71
+ // route qui cherche dans tous ces types. Presentation prend la PREMIÈRE route qui
72
+ // correspond à l'adresse : une route par type ne trouverait jamais le second.
73
+ const byBase = new Map<string, (typeof slugTypes)[number][]>()
70
74
  for (const t of collections) {
71
75
  const p = prefixOf(t)
72
76
  const base = p && p !== '/' ? p : ''
77
+ byBase.set(base, [...(byBase.get(base) ?? []), t])
78
+ }
79
+ for (const [base, types] of byBase) {
80
+ const match = types.map((t) => `(_type == ${quote(t.type)} && ${t.slugField}.current == $slug)`)
73
81
  // `:slug+` : un slug peut avoir plusieurs niveaux (« telecom/projets ») ; la valeur
74
82
  // transmise à $slug est alors le slug complet (URLPattern de Presentation).
75
- out.push({route: at(`${base}/:slug+`), filter: `_type == ${quote(t.type)} && ${t.slugField}.current == $slug${lang}`})
83
+ out.push({
84
+ route: at(`${base}/:slug+`),
85
+ filter: types.length === 1 && types[0] ? `_type == ${quote(types[0].type)} && ${types[0].slugField}.current == $slug${lang}` : `(${match.join(' || ')})${lang}`,
86
+ })
76
87
  }
77
88
  }
78
89
  return out
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
4
4
  * le vérifie.
5
5
  */
6
- export const KIT_VERSION = '2.44.1'
6
+ export const KIT_VERSION = '2.44.2'