@easy-web/core 1.9.1 → 1.10.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 (47) hide show
  1. package/README.md +25 -6
  2. package/dist/contracts/capabilities.d.ts +3 -0
  3. package/dist/contracts/capabilities.d.ts.map +1 -1
  4. package/dist/contracts/index.d.ts +1 -0
  5. package/dist/contracts/index.d.ts.map +1 -1
  6. package/dist/contracts/index.js +1 -0
  7. package/dist/contracts/index.js.map +1 -1
  8. package/dist/contracts/ordering.d.ts +6 -0
  9. package/dist/contracts/ordering.d.ts.map +1 -0
  10. package/dist/contracts/ordering.js +22 -0
  11. package/dist/contracts/ordering.js.map +1 -0
  12. package/dist/contracts/traits.d.ts +4 -0
  13. package/dist/contracts/traits.d.ts.map +1 -1
  14. package/dist/contracts/traits.js +3 -1
  15. package/dist/contracts/traits.js.map +1 -1
  16. package/dist/recipes/content-site.d.ts.map +1 -1
  17. package/dist/recipes/content-site.js +209 -42
  18. package/dist/recipes/content-site.js.map +1 -1
  19. package/dist/recipes/shell-recipe.d.ts +3 -0
  20. package/dist/recipes/shell-recipe.d.ts.map +1 -1
  21. package/dist/recipes/shell-recipe.js +116 -6
  22. package/dist/recipes/shell-recipe.js.map +1 -1
  23. package/dist/seo/index.d.ts +5 -0
  24. package/dist/seo/index.d.ts.map +1 -1
  25. package/dist/seo/index.js +7 -3
  26. package/dist/seo/index.js.map +1 -1
  27. package/dist/seo/rendered-sitemap-alternates.d.ts +7 -0
  28. package/dist/seo/rendered-sitemap-alternates.d.ts.map +1 -0
  29. package/dist/seo/rendered-sitemap-alternates.js +232 -0
  30. package/dist/seo/rendered-sitemap-alternates.js.map +1 -0
  31. package/package.json +1 -1
  32. package/src/contracts/__tests__/content-composition.test.ts +17 -0
  33. package/src/contracts/__tests__/ordering.test.ts +34 -0
  34. package/src/contracts/capabilities.ts +4 -0
  35. package/src/contracts/index.ts +1 -0
  36. package/src/contracts/ordering.ts +33 -0
  37. package/src/contracts/traits.ts +4 -1
  38. package/src/recipes/__tests__/content-site.test.ts +79 -2
  39. package/src/recipes/__tests__/shell-recipe.test.ts +23 -0
  40. package/src/recipes/content-site.ts +212 -48
  41. package/src/recipes/shell-recipe.ts +120 -6
  42. package/src/seo/__tests__/integration.test.ts +28 -0
  43. package/src/seo/__tests__/rendered-sitemap-alternates.test.ts +127 -0
  44. package/src/seo/__tests__/sitemap-options.test.ts +7 -7
  45. package/src/seo/index.ts +17 -3
  46. package/src/seo/rendered-sitemap-alternates.ts +231 -0
  47. package/src/type-tests/contracts.ts +6 -0
package/README.md CHANGED
@@ -120,15 +120,30 @@ featured presentation slot merely by defining an image.
120
120
  `createContentSiteRecipes(composition)` from `@easy-web/core/recipes` connects a
121
121
  validated composition to shell navigation and a `content.pages` recipe. Its
122
122
  `generatedContentCompositionSchema` deliberately accepts a smaller implemented
123
- subset than the generic contract: one locale, `title`/`slug`/`body`, optional
124
- `summary`/`image`, list/detail bindings and optional navigation or `cms-admin`. Other valid
123
+ subset than the generic contract: one locale or the DE/EN pair,
124
+ `title`/`slug`/`body`, optional
125
+ `summary`/`image`/`order`, list/detail bindings and optional navigation or `cms-admin`. Other valid
125
126
  contract selections fail with an explicit not-yet-supported diagnostic.
126
127
 
127
128
  The recipe generates Astro collections from shared trait schemas, deterministic
128
129
  example content, contract-checked entry adapters and list/detail pages using Card,
129
- Media and Prose. A body becomes `HasBody` only after Astro renders it. Content
130
+ Media and Prose. The published `orderTraitSchema`/`HasOrder` pair remains required;
131
+ generated collections use the additional `optionalOrderTraitSchema`/`HasOptionalOrder`
132
+ shape so entries may omit an order. Present values must be finite integers (fractional
133
+ values are rejected by the existing integer contract), including
134
+ negative and zero; missing values sort last. Equal values sort by slug using the
135
+ explicit content locale, then by collection ID using ordinal comparison. Sites
136
+ without the `order` trait retain their existing slug/href ordering. A body becomes
137
+ `HasBody` only after Astro renders it. Content
130
138
  roles and bindings are logical graph contributions, not output filenames.
131
139
  `primary` is a graph role; it does not select a homepage automatically.
140
+ In DE/EN mode, entries live below their locale folder and require matching
141
+ `locale` and `translationKey` data. Each locale's label, route, title, summary,
142
+ slug and markdown body remains independently editable; detail alternates are
143
+ created only when a translation key has more than one locale. The generated
144
+ shell localizes navigation and adds the actual translated routes to its
145
+ canonical/head/sitemap configuration. Localized links and SEO URLs honor Astro's
146
+ configured `base` path and trailing-slash mode.
132
147
  `@easy-web/cms-adapters` supplies `createCmsContentSiteRecipes` for the CMS-enabled
133
148
  path, consuming the same composition without replacing core's schemas or routes.
134
149
  Core's optional `ContentSiteOptions` lets first-party recipes choose an asset
@@ -138,8 +153,12 @@ user-configurable JavaScript or a post-generation config merge.
138
153
  Application-auth composition remains unsupported.
139
154
 
140
155
  Generated content sites require core `^1.6.0`, the first release with the trait
141
- schemas used in their collections and adapters, even without images. This does
142
- not raise the shell-only floor of `^1.5.0`. CMS composition adds its own higher
143
- runtime requirement.
156
+ schemas used in their collections and adapters, even without images. Selecting
157
+ `order` or bilingual content raises the core and CMS floor to `^1.10.0` for
158
+ the new ordering or alternate reconciliation APIs. These unpublished minimums
159
+ require both features to be released together in 1.10.0 before registry consumption;
160
+ otherwise the later feature's minimum must be raised to its first release.
161
+ This does not raise the shell-only floor of `^1.5.0`. CMS compositions without
162
+ either feature require `^1.9.0`.
144
163
 
145
164
  This package is published as part of the fixed `@easy-web/*` family through the Changesets and npm Trusted Publishing workflow.
@@ -20,6 +20,9 @@ export interface HasPhotos {
20
20
  export interface HasOrder {
21
21
  readonly order: number;
22
22
  }
23
+ export interface HasOptionalOrder {
24
+ readonly order?: number;
25
+ }
23
26
  export interface HasTaxonomy {
24
27
  readonly taxonomy: readonly string[];
25
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/contracts/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MA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AC9B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAEpD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,QAAQ,CAAC,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC"}
@@ -6,4 +6,5 @@ export * from './publish.js';
6
6
  export * from './types.js';
7
7
  export * from './traits.js';
8
8
  export * from './jsonld.js';
9
+ export * from './ordering.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
@@ -6,4 +6,5 @@ export * from './publish.js';
6
6
  export * from './types.js';
7
7
  export * from './traits.js';
8
8
  export * from './jsonld.js';
9
+ export * from './ordering.js';
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { HasOptionalOrder, HasSlug } from './capabilities.js';
2
+ export interface OrderedContentEntry extends HasOptionalOrder, HasSlug {
3
+ readonly id: string;
4
+ }
5
+ export declare function compareContentOrder(left: OrderedContentEntry, right: OrderedContentEntry, locale: string): number;
6
+ //# sourceMappingURL=ordering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordering.d.ts","sourceRoot":"","sources":["../../src/contracts/ordering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB,EAAE,OAAO;IACpE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAYD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,MAAM,GACb,MAAM,CAYR"}
@@ -0,0 +1,22 @@
1
+ function compareIdentifiers(left, right) {
2
+ return left < right ? -1 : left > right ? 1 : 0;
3
+ }
4
+ function assertValidOrder(order) {
5
+ if (order !== undefined && (!Number.isFinite(order) || !Number.isInteger(order))) {
6
+ throw new TypeError('Content order must be a finite integer');
7
+ }
8
+ }
9
+ export function compareContentOrder(left, right, locale) {
10
+ assertValidOrder(left.order);
11
+ assertValidOrder(right.order);
12
+ if (left.order === undefined && right.order !== undefined)
13
+ return 1;
14
+ if (left.order !== undefined && right.order === undefined)
15
+ return -1;
16
+ if (left.order !== undefined && right.order !== undefined && left.order !== right.order) {
17
+ return left.order < right.order ? -1 : 1;
18
+ }
19
+ const slugOrder = left.slug.localeCompare(right.slug, locale);
20
+ return slugOrder === 0 ? compareIdentifiers(left.id, right.id) : slugOrder;
21
+ }
22
+ //# sourceMappingURL=ordering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordering.js","sourceRoot":"","sources":["../../src/contracts/ordering.ts"],"names":[],"mappings":"AAMA,SAAS,kBAAkB,CAAC,IAAY,EAAE,KAAa;IACrD,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAyB;IACjD,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACjF,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,IAAyB,EACzB,KAA0B,EAC1B,MAAc;IAEd,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE9B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IACpE,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,CAAC;IACrE,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC;QACxF,OAAO,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9D,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7E,CAAC"}
@@ -50,6 +50,9 @@ export declare const photosTraitSchema: z.ZodReadonly<z.ZodObject<{
50
50
  export declare const orderTraitSchema: z.ZodReadonly<z.ZodObject<{
51
51
  order: z.ZodNumber;
52
52
  }, z.core.$strict>>;
53
+ export declare const optionalOrderTraitSchema: z.ZodReadonly<z.ZodObject<{
54
+ order: z.ZodOptional<z.ZodNumber>;
55
+ }, z.core.$strict>>;
53
56
  export declare const taxonomyTraitSchema: z.ZodReadonly<z.ZodObject<{
54
57
  taxonomy: z.ZodReadonly<z.ZodArray<z.ZodString>>;
55
58
  }, z.core.$strict>>;
@@ -85,6 +88,7 @@ export type BodyTrait = z.infer<typeof bodyTraitSchema>;
85
88
  export type ImageTrait = z.infer<typeof imageTraitSchema>;
86
89
  export type PhotosTrait = z.infer<typeof photosTraitSchema>;
87
90
  export type OrderTrait = z.infer<typeof orderTraitSchema>;
91
+ export type OptionalOrderTrait = z.infer<typeof optionalOrderTraitSchema>;
88
92
  export type TaxonomyTrait = z.infer<typeof taxonomyTraitSchema>;
89
93
  export type PublicationTrait = z.infer<typeof publicationTraitSchema>;
90
94
  export type ScheduleTrait = z.infer<typeof scheduleTraitSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../../src/contracts/traits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAmC9B,eAAO,MAAM,aAAa,0JAehB,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAAwB,CAAC;AACxD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,gBAAgB;;mBAA2C,CAAC;AACzE,eAAO,MAAM,eAAe;;mBAA0C,CAAC;AACvE,eAAO,MAAM,kBAAkB;;mBAA6C,CAAC;AAC7E,eAAO,MAAM,eAAe;;mBAA0C,CAAC;AACvE,eAAO,MAAM,gBAAgB;;;;;;;;mBAA2C,CAAC;AACzE,eAAO,MAAM,iBAAiB;;;;;;;;mBAA4C,CAAC;AAC3E,eAAO,MAAM,gBAAgB;;mBAA2C,CAAC;AACzE,eAAO,MAAM,mBAAmB;;mBAA8C,CAAC;AAC/E,eAAO,MAAM,sBAAsB;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20,8 @@ const summaryShape = { summary: z.string().min(1) };
20
20
  const bodyShape = { body: z.string().min(1) };
21
21
  const imageShape = { image: imageSchema };
22
22
  const photosShape = { photos: z.array(imageSchema).readonly() };
23
- const orderShape = { order: z.number().int() };
23
+ const orderShape = { order: z.number().finite().int() };
24
+ const optionalOrderShape = { order: z.number().finite().int().optional() };
24
25
  const taxonomyShape = { taxonomy: z.array(z.string().min(1)).readonly() };
25
26
  const publicationShape = { publishDate: z.date(), modifiedDate: z.date().optional() };
26
27
  const scheduleShape = { startDate: z.date(), endDate: z.date().optional() };
@@ -52,6 +53,7 @@ export const bodyTraitSchema = z.object(bodyShape).strict().readonly();
52
53
  export const imageTraitSchema = z.object(imageShape).strict().readonly();
53
54
  export const photosTraitSchema = z.object(photosShape).strict().readonly();
54
55
  export const orderTraitSchema = z.object(orderShape).strict().readonly();
56
+ export const optionalOrderTraitSchema = z.object(optionalOrderShape).strict().readonly();
55
57
  export const taxonomyTraitSchema = z.object(taxonomyShape).strict().readonly();
56
58
  export const publicationTraitSchema = z.object(publicationShape).strict().readonly();
57
59
  export const scheduleTraitSchema = z.object(scheduleShape).strict().readonly();
@@ -1 +1 @@
1
- {"version":3,"file":"traits.js","sourceRoot":"","sources":["../../src/contracts/traits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC;IAChC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE;CACnD,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,GAAG,EAAE,iBAAi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E,aAAa;CACqC,CAAC;AAE/D,MAAM,UAAU,yBAAyB,CAAC,MAA+B;IACvE,MAAM,KAAK,GAAiC,EAAE,CAAC;IAC/C,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC7C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"content-site.d.ts","sourceRoot":"","sources":["../../src/recipes/content-site.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAK9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,YAAY,CAAC;AAOtE,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACpD;AAED,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA+B5C,CAAC;AA4IH,gGAAgG;AAChG,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,GAAE,kBAAuB,GAAG;IACjG,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;IACnD,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CACpC,CAmCA"}
1
+ {"version":3,"file":"content-site.d.ts","sourceRoot":"","sources":["../../src/recipes/content-site.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAK9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,YAAY,CAAC;AAatE,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACpD;AAED,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAqC5C,CAAC;AAqQH,gGAAgG;AAChG,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,GAAE,kBAAuB,GAAG;IACjG,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;IACnD,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CACpC,CAkEA"}
@@ -2,17 +2,25 @@ import { z } from 'astro/zod';
2
2
  import { posix } from 'node:path';
3
3
  import { contentCompositionSchema, defaultReservedContentRoutes } from '../contracts/content-composition.js';
4
4
  import { buildShellFiles, shellRecipe } from './shell-recipe.js';
5
- const supportedTraits = new Set(['title', 'slug', 'summary', 'image', 'body']);
5
+ const supportedTraits = new Set(['title', 'slug', 'summary', 'image', 'body', 'order']);
6
6
  const supportedBindings = new Set(['list', 'detail', 'navigation', 'cms-admin']);
7
7
  const contentRuntimeRange = '^1.6.0';
8
+ const orderedContentRuntimeRange = '^1.10.0';
9
+ function contentRuntimeFor(composition) {
10
+ return composition.contentLocales.length > 1 || composition.contentTypes.some((type) => type.traits.includes('order'))
11
+ ? orderedContentRuntimeRange : contentRuntimeRange;
12
+ }
8
13
  export const generatedContentCompositionSchema = contentCompositionSchema.superRefine((composition, context) => {
9
- if (composition.contentLocales.length !== 1) {
10
- context.addIssue({ code: 'custom', path: ['contentLocales'], message: 'Content generation currently requires exactly one locale' });
14
+ const locales = composition.contentLocales;
15
+ const localeIds = locales;
16
+ if (locales.length > 1 && (locales.length !== 2 || !localeIds.includes('de') || !localeIds.includes('en'))) {
17
+ context.addIssue({ code: 'custom', path: ['contentLocales'], message: 'Content generation supports one locale or the bilingual DE/EN pair' });
11
18
  }
12
19
  if (!composition.contentTypes.length) {
13
20
  context.addIssue({ code: 'custom', path: ['contentTypes'], message: 'Content generation requires at least one content type' });
14
21
  }
15
22
  const routes = [];
23
+ const localeRoots = new Set(locales.slice(1).map((locale) => `/${locale}`));
16
24
  composition.contentTypes.forEach((type, index) => {
17
25
  const path = ['contentTypes', index];
18
26
  for (const trait of type.traits) {
@@ -32,7 +40,10 @@ export const generatedContentCompositionSchema = contentCompositionSchema.superR
32
40
  || defaultReservedContentRoutes.some((reserved) => reserved !== '/' && `${base}/`.startsWith(reserved))) {
33
41
  context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Unsupported generated content route "${route}"; use non-reserved lowercase path segments` });
34
42
  }
35
- if (routes.some((other) => base.startsWith(`${other}/`) || other.startsWith(`${base}/`))) {
43
+ if (localeRoots.has(base)) {
44
+ context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Generated content route "${route}" conflicts with the localized home page` });
45
+ }
46
+ if (routes.some((other) => base === other || base.startsWith(`${other}/`) || other.startsWith(`${base}/`))) {
36
47
  context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Generated list/detail routes overlap at "${route}"` });
37
48
  }
38
49
  routes.push(base);
@@ -42,52 +53,104 @@ export const generatedContentCompositionSchema = contentCompositionSchema.superR
42
53
  function routeBase(type, locale) {
43
54
  return type.routes[locale].replace(/\/$/, '');
44
55
  }
45
- function collectionSchema(type) {
56
+ function collectionSchema(type, locales) {
46
57
  const shapes = ['...titleTraitSchema.unwrap().shape', '...slugTraitSchema.unwrap().shape'];
47
58
  if (type.traits.includes('summary'))
48
59
  shapes.push('...summaryTraitSchema.unwrap().shape');
49
60
  if (type.traits.includes('image')) {
50
61
  shapes.push('image: imageTraitSchema.unwrap().shape.image.unwrap().extend({ src: image() })');
51
62
  }
63
+ if (locales.length > 1) {
64
+ shapes.push(`locale: z.enum(${JSON.stringify(locales)})`);
65
+ shapes.push("translationKey: z.string().min(1).regex(/\\S/, 'Darf nicht nur aus Leerzeichen bestehen.')");
66
+ }
67
+ if (type.traits.includes('order'))
68
+ shapes.push('...optionalOrderTraitSchema.unwrap().shape');
52
69
  // File-based IDs keep duplicate public slugs visible to route validation.
53
70
  return `${JSON.stringify(type.id)}: defineCollection({
54
71
  loader: glob({ pattern: '**/*.md', base: ${JSON.stringify(`./src/content/${type.id}`)}, generateId: ({ entry }) => entry.replace(/\\.md$/, '') }),
55
72
  schema: ${type.traits.includes('image') ? '({ image }) => ' : ''}z.object({ ${shapes.join(', ')} }).strict(),
56
73
  })`;
57
74
  }
58
- function adapterSource(type, locale, index) {
59
- const contracts = ['HasTitle', 'HasSlug', ...(type.traits.includes('summary') ? ['HasSummary'] : []), ...(type.traits.includes('image') ? ['HasImage'] : [])];
75
+ function adapterSource(type, index, locales) {
76
+ const contracts = [
77
+ 'HasTitle',
78
+ 'HasSlug',
79
+ ...(type.traits.includes('summary') ? ['HasSummary'] : []),
80
+ ...(type.traits.includes('image') ? ['HasImage'] : []),
81
+ ...(type.traits.includes('order') ? ['HasOptionalOrder'] : []),
82
+ ];
83
+ const localeType = locales.map((locale) => JSON.stringify(locale)).join(' | ');
84
+ const defaultLocale = locales[0];
85
+ const localized = locales.length > 1;
60
86
  return `import type { CollectionEntry } from 'astro:content';
61
87
  import { assertImplements, type Item, type Linkable, ${contracts.map((name) => `type ${name}`).join(', ')} } from '@easy-web/core/contracts';
62
88
  import { composition } from '../../content/definitions';
63
89
 
64
90
  type Entry = CollectionEntry<${JSON.stringify(type.id)}>;
65
91
  assertImplements<Entry['data'], ${contracts.join(' & ')}>();
66
-
67
- export function toItem(entry: Entry): Item & Linkable {
92
+ ${localized ? `type ContentLocale = ${localeType};\n` : ''}
93
+ export function toItem(entry: Entry${localized ? `, locale: ContentLocale = ${JSON.stringify(defaultLocale)}, basePath = import.meta.env.BASE_URL.replace(/\\/$/, '')` : ''}): Item & Linkable {
68
94
  const data = entry.data;
69
95
  return {
70
96
  title: data.title,
71
97
  ${type.traits.includes('summary') ? 'description: data.summary,' : ''}
72
98
  ${type.traits.includes('image') ? 'image: data.image,' : ''}
73
- href: composition.contentTypes[${index}].routes[${JSON.stringify(locale)}].replace(/\\/$/, '') + '/' + data.slug + '/',
99
+ href: ${localized ? `basePath + ` : `import.meta.env.BASE_URL.replace(/\\/$/, '') + `}composition.contentTypes[${index}].routes[${localized ? 'locale' : JSON.stringify(defaultLocale)}].replace(/\\/$/, '') + '/' + data.slug + '/',
74
100
  };
75
101
  }
76
102
  `;
77
103
  }
78
- function listSource(type, locale) {
104
+ function listSource(type, locale, composition) {
79
105
  const prefix = '../'.repeat(routeBase(type, locale).split('/').length);
106
+ const localized = composition.contentLocales.length > 1;
107
+ const localeFilter = localized ? `, ({ data }) => data.locale === ${JSON.stringify(locale)}` : '';
108
+ const localizedPaths = JSON.stringify([Object.fromEntries(composition.contentLocales.map((itemLocale) => [itemLocale, `${routeBase(type, itemLocale)}/`]))]);
109
+ const localizedBaseSetup = localized ? `
110
+ const routePath = ${JSON.stringify(`${routeBase(type, locale)}/`)};
111
+ const pagePath = Astro.url.pathname.replace(/\\/+$/, '') || '/';
112
+ const routeWithoutSlash = routePath.replace(/\\/+$/, '') || '/';
113
+ const sitePrefix = routeWithoutSlash === '/' ? (pagePath === '/' ? '' : pagePath)
114
+ : pagePath.endsWith(routeWithoutSlash) ? pagePath.slice(0, -routeWithoutSlash.length) : '';
115
+ ` : '';
116
+ const alternateSetup = localized ? `
117
+ const localizedPathGroups = ${localizedPaths};
118
+ const alternates = getAlternateLinks({
119
+ path: routePath, locales: ${JSON.stringify(composition.contentLocales)},
120
+ defaultLocale: ${JSON.stringify(composition.contentLocales[0])},
121
+ baseUrl: new URL(sitePrefix ? sitePrefix + '/' : '/', Astro.site?.toString() ?? 'https://replace-with-your-domain.example').toString(),
122
+ localizedPaths: localizedPathGroups,
123
+ trailingSlash: ambientTrailingSlash(),
124
+ });
125
+ const alternateHref = alternates.find(({ hreflang }) => hreflang !== ${JSON.stringify(locale)} && hreflang !== 'x-default')?.href;
126
+ ` : '';
127
+ const localeArgument = localized ? `, ${JSON.stringify(locale)}, sitePrefix` : '';
128
+ const itemMapping = type.traits.includes('order')
129
+ ? `.sort((left, right) => compareContentOrder(
130
+ { order: left.data.order, slug: left.data.slug, id: left.id },
131
+ { order: right.data.order, slug: right.data.slug, id: right.id },
132
+ ${JSON.stringify(locale)},
133
+ ))
134
+ ${localized ? `.map((entry) => toItem(entry${localeArgument}))` : '.map(toItem)'}`
135
+ : localized
136
+ ? `.sort((left, right) => left.data.slug < right.data.slug ? -1 : left.data.slug > right.data.slug ? 1 : left.id < right.id ? -1 : left.id > right.id ? 1 : 0)
137
+ .map((entry) => toItem(entry${localeArgument}))`
138
+ : `.map(toItem).sort((left, right) => left.href < right.href ? -1 : left.href > right.href ? 1 : 0)`;
80
139
  return `---
81
140
  import { getCollection } from 'astro:content';
82
141
  import Base from '${prefix}layouts/Base.astro';
83
142
  import { toItem } from '${prefix}lib/content/${type.id}';
143
+ ${type.traits.includes('order') ? "import { compareContentOrder } from '@easy-web/core/contracts';" : ''}
84
144
  import Card from '@easy-web/core/components/Card.astro';
85
145
  import CardGrid from '@easy-web/core/components/CardGrid.astro';
146
+ ${localized ? "import { getAlternateLinks, ambientTrailingSlash } from '@easy-web/core/i18n';" : ''}
86
147
 
87
- const items = (await getCollection(${JSON.stringify(type.id)}))
88
- .map(toItem).sort((left, right) => left.href < right.href ? -1 : left.href > right.href ? 1 : 0);
148
+ ${localizedBaseSetup}
149
+ const items = (await getCollection(${JSON.stringify(type.id)}${localeFilter}))
150
+ ${itemMapping};
151
+ ${alternateSetup}
89
152
  ---
90
- <Base title={${JSON.stringify(type.labels[locale])}}>
153
+ <Base title={${JSON.stringify(type.labels[locale])}}${localized ? ` locale={${JSON.stringify(locale)}} basePath={sitePrefix} alternates={alternates} alternateHref={alternateHref}` : ''}>
91
154
  <h1>{${JSON.stringify(type.labels[locale])}}</h1>
92
155
  <CardGrid>
93
156
  {items.map((item) => <Card item={item} />)}
@@ -95,32 +158,84 @@ const items = (await getCollection(${JSON.stringify(type.id)}))
95
158
  </Base>
96
159
  `;
97
160
  }
98
- function detailSource(type, locale) {
161
+ function detailSource(type, locale, composition) {
99
162
  const prefix = '../'.repeat(routeBase(type, locale).split('/').length);
163
+ const localized = composition.contentLocales.length > 1;
164
+ const currentRoute = JSON.stringify(`${routeBase(type, locale)}/`);
165
+ const alternateListRoute = localized
166
+ ? JSON.stringify(`${routeBase(type, composition.contentLocales.find((itemLocale) => itemLocale !== locale))}/`)
167
+ : "''";
168
+ const localizedSetup = localized ? `
169
+ const routeBases = ${JSON.stringify(Object.fromEntries(composition.contentLocales.map((itemLocale) => [
170
+ itemLocale, routeBase(type, itemLocale),
171
+ ])))};
172
+ ` : '';
173
+ const localizedMap = localized ? `
174
+ const translations = allEntries.filter((candidate) => candidate.data.translationKey === entry.data.translationKey);
175
+ const translatedLocales = new Set<string>();
176
+ for (const candidate of translations) {
177
+ if (translatedLocales.has(candidate.data.locale)) {
178
+ throw new Error('Duplicate translationKey in locale: ' + candidate.data.translationKey + ' (' + candidate.data.locale + ')');
179
+ }
180
+ translatedLocales.add(candidate.data.locale);
181
+ }
182
+ const localizedPaths = translations.length > 1
183
+ ? Object.fromEntries(translations.map((candidate) => [
184
+ candidate.data.locale, routeBases[candidate.data.locale] + '/' + candidate.data.slug + '/',
185
+ ]))
186
+ : undefined;
187
+ return { params: { slug: entry.data.slug }, props: { entry, localizedPaths } };
188
+ ` : `
189
+ return { params: { slug: entry.data.slug }, props: { entry } };
190
+ `;
191
+ const localeArgument = localized ? `, ${JSON.stringify(locale)}` : '';
100
192
  return `---
101
193
  import { getCollection, render, type CollectionEntry } from 'astro:content';
102
194
  import type { Rendered, Item, Linkable } from '@easy-web/core/contracts';
103
195
  import Base from '${prefix}layouts/Base.astro';
104
196
  import { toItem } from '${prefix}lib/content/${type.id}';
105
197
  import Prose from '@easy-web/core/components/Prose.astro';
198
+ ${localized ? "import { getAlternateLinks, ambientTrailingSlash } from '@easy-web/core/i18n';" : ''}
106
199
  ${type.traits.includes('image') ? "import Media from '@easy-web/core/components/Media.astro';" : ''}
200
+ interface Props { entry: CollectionEntry<${JSON.stringify(type.id)}>${localized ? '; localizedPaths?: Record<string, string>' : ''} }
201
+ type StaticPath = { params: { slug: string }; props: Props };
107
202
 
108
- export async function getStaticPaths() {
109
- const entries = await getCollection(${JSON.stringify(type.id)});
203
+ export async function getStaticPaths(): Promise<StaticPath[]> {
204
+ const allEntries = await getCollection(${JSON.stringify(type.id)});
205
+ const entries = ${localized ? `allEntries.filter((entry) => entry.data.locale === ${JSON.stringify(locale)})` : 'allEntries'};
110
206
  const seen = new Set<string>();
207
+ ${localizedSetup}
111
208
  return entries.map((entry) => {
112
209
  if (seen.has(entry.data.slug)) throw new Error('Duplicate content slug: ' + entry.data.slug);
113
210
  seen.add(entry.data.slug);
114
- return { params: { slug: entry.data.slug }, props: { entry } };
115
- });
211
+ ${localizedMap} });
116
212
  }
117
213
 
118
- interface Props { entry: CollectionEntry<${JSON.stringify(type.id)}> }
119
- const { entry } = Astro.props;
120
- const rendered: Rendered<Item & Linkable> = { ...toItem(entry), ...(await render(entry)) };
214
+ const { entry${localized ? ', localizedPaths' : ''} } = Astro.props;
215
+ ${localized ? `
216
+ const localizedPathGroups = localizedPaths
217
+ ? [localizedPaths]
218
+ : undefined;
219
+ const routePath = ${currentRoute} + entry.data.slug + '/';
220
+ const pagePath = Astro.url.pathname.replace(/\\/+$/, '') || '/';
221
+ const routeWithoutSlash = routePath.replace(/\\/+$/, '') || '/';
222
+ const sitePrefix = routeWithoutSlash === '/' ? (pagePath === '/' ? '' : pagePath)
223
+ : pagePath.endsWith(routeWithoutSlash) ? pagePath.slice(0, -routeWithoutSlash.length) : '';
224
+ const alternates = localizedPathGroups ? getAlternateLinks({
225
+ path: routePath,
226
+ locales: ${JSON.stringify(composition.contentLocales)},
227
+ defaultLocale: ${JSON.stringify(composition.contentLocales[0])},
228
+ baseUrl: new URL(sitePrefix ? sitePrefix + '/' : '/', Astro.site?.toString() ?? 'https://replace-with-your-domain.example').toString(),
229
+ localizedPaths: localizedPathGroups,
230
+ trailingSlash: ambientTrailingSlash(),
231
+ }) : [];
232
+ const alternateHref = alternates.find(({ hreflang }) => hreflang !== ${JSON.stringify(locale)} && hreflang !== 'x-default')?.href
233
+ ?? sitePrefix + ${alternateListRoute};
234
+ ` : ''}
235
+ const rendered: Rendered<Item & Linkable> = { ...toItem(entry${localeArgument}), ...(await render(entry)) };
121
236
  const { Content } = rendered;
122
237
  ---
123
- <Base title={rendered.title} description={rendered.description}${type.traits.includes('image') ? ' image={rendered.image?.src && (typeof rendered.image.src === \'string\' ? rendered.image.src : rendered.image.src.src)}' : ''}>
238
+ <Base title={rendered.title} description={rendered.description}${localized ? ` locale={${JSON.stringify(locale)}} basePath={sitePrefix} alternates={alternates} alternateHref={alternateHref}` : ''}${type.traits.includes('image') ? ' image={rendered.image?.src && (typeof rendered.image.src === \'string\' ? rendered.image.src : rendered.image.src.src)}' : ''}>
124
239
  <Prose>
125
240
  <h1>{rendered.title}</h1>
126
241
  {rendered.description && <p>{rendered.description}</p>}
@@ -131,24 +246,26 @@ const { Content } = rendered;
131
246
  `;
132
247
  }
133
248
  function contentFiles(composition, options) {
134
- const locale = composition.contentLocales[0];
249
+ const locales = composition.contentLocales;
250
+ const localized = locales.length > 1;
251
+ const runtimeRange = contentRuntimeFor(composition);
135
252
  const mediaFolder = z.string().regex(/^src\/assets(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/)
136
253
  .parse(options.mediaFolder ?? 'src/assets');
137
254
  const exampleImage = `${mediaFolder}/content-example.svg`;
138
255
  const files = [
139
256
  { path: 'src/content/definitions.ts', content: `import { defineCollection, z } from 'astro:content';
140
257
  import { glob } from 'astro/loaders';
141
- import { titleTraitSchema, slugTraitSchema${composition.contentTypes.some((type) => type.traits.includes('summary')) ? ', summaryTraitSchema' : ''}${composition.contentTypes.some((type) => type.traits.includes('image')) ? ', imageTraitSchema' : ''} } from '@easy-web/core/contracts';
258
+ import { titleTraitSchema, slugTraitSchema${composition.contentTypes.some((type) => type.traits.includes('summary')) ? ', summaryTraitSchema' : ''}${composition.contentTypes.some((type) => type.traits.includes('image')) ? ', imageTraitSchema' : ''}${composition.contentTypes.some((type) => type.traits.includes('order')) ? ', optionalOrderTraitSchema' : ''} } from '@easy-web/core/contracts';
142
259
 
143
260
  export const composition = ${JSON.stringify(composition, null, 2)} as const;
144
261
 
145
262
  export const collections = {
146
- ${composition.contentTypes.map(collectionSchema).join(',\n ')},
263
+ ${composition.contentTypes.map((type) => collectionSchema(type, locales)).join(',\n ')},
147
264
  };
148
265
  ` },
149
266
  { path: 'src/content.config.ts', content: "export { collections } from './content/definitions';\n" },
150
267
  { path: 'package.json', content: `${JSON.stringify({ dependencies: {
151
- '@easy-web/core': contentRuntimeRange,
268
+ '@easy-web/core': runtimeRange,
152
269
  ...(composition.contentTypes.some((type) => type.traits.includes('image')) ? { sharp: '^0.35.0' } : {}),
153
270
  } }, null, 2)}\n` },
154
271
  ];
@@ -156,42 +273,92 @@ export const collections = {
156
273
  files.push({ path: exampleImage, content: '<svg xmlns="http://www.w3.org/2000/svg" width="640" height="360" viewBox="0 0 640 360"><rect width="640" height="360" fill="#334155"/><circle cx="320" cy="180" r="90" fill="#94a3b8"/></svg>\n' });
157
274
  }
158
275
  for (const [index, type] of composition.contentTypes.entries()) {
159
- const data = {
160
- title: `${type.labels[locale]} - ${locale === 'de' ? 'Beispiel' : 'Example'}`,
161
- slug: 'example',
162
- ...(type.traits.includes('summary') ? { summary: locale === 'de' ? 'Generierter Beispielinhalt.' : 'Generated example content.' } : {}),
163
- ...(type.traits.includes('image') ? { image: { src: posix.relative(`src/content/${type.id}`, exampleImage), alt: locale === 'de' ? 'Kreis auf dunklem Hintergrund' : 'Circle on a dark background' } } : {}),
164
- };
165
- const base = routeBase(type, locale).slice(1);
166
- files.push({ path: `src/content/${type.id}/example.md`, content: `---\n${JSON.stringify(data, null, 2)}\n---\n\n${locale === 'de' ? 'Ersetze diesen Beispielinhalt vor der Veroeffentlichung.' : 'Replace this example content before production.'}\n` }, { path: `src/lib/content/${type.id}.ts`, content: adapterSource(type, locale, index) }, { path: `src/pages/${base}/index.astro`, content: listSource(type, locale) }, { path: `src/pages/${base}/[slug].astro`, content: detailSource(type, locale) });
276
+ files.push({ path: `src/lib/content/${type.id}.ts`, content: adapterSource(type, index, locales) });
277
+ for (const locale of locales) {
278
+ const isGerman = locale === 'de';
279
+ const data = {
280
+ title: `${type.labels[locale]} - ${isGerman ? 'Beispiel' : 'Example'}`,
281
+ slug: 'example',
282
+ ...(localized ? { locale, translationKey: 'example' } : {}),
283
+ ...(type.traits.includes('summary') ? { summary: isGerman ? 'Generierter Beispielinhalt.' : 'Generated example content.' } : {}),
284
+ ...(type.traits.includes('image') ? {
285
+ image: {
286
+ src: posix.relative(`src/content/${type.id}${localized ? `/${locale}` : ''}`, exampleImage),
287
+ alt: isGerman ? 'Kreis auf dunklem Hintergrund' : 'Circle on a dark background',
288
+ },
289
+ } : {}),
290
+ };
291
+ const contentFolder = `src/content/${type.id}${localized ? `/${locale}` : ''}`;
292
+ const body = isGerman ? 'Ersetze diesen Beispielinhalt vor der Veroeffentlichung.' : 'Replace this example content before production.';
293
+ files.push({
294
+ path: `${contentFolder}/example.md`,
295
+ content: `---\n${JSON.stringify(data, null, 2)}\n---\n\n${body}\n`,
296
+ });
297
+ }
298
+ for (const locale of locales) {
299
+ const route = routeBase(type, locale).slice(1);
300
+ files.push({ path: `src/pages/${route}/index.astro`, content: listSource(type, locale, composition) }, { path: `src/pages/${route}/[slug].astro`, content: detailSource(type, locale, composition) });
301
+ }
167
302
  }
168
303
  return files;
169
304
  }
170
305
  /** Bind package-owned content generation to a validated composition, independently of a CMS. */
171
306
  export function createContentSiteRecipes(rawComposition, options = {}) {
172
307
  const composition = generatedContentCompositionSchema.parse(rawComposition);
173
- const locale = composition.contentLocales[0];
308
+ const locales = composition.contentLocales;
309
+ const locale = locales[0];
310
+ const runtimeRange = contentRuntimeFor(composition);
311
+ const navigationByLocale = Object.fromEntries(locales.map((contentLocale) => [
312
+ contentLocale,
313
+ composition.contentTypes.filter((type) => type.bindings.includes('navigation'))
314
+ .map((type) => ({ label: type.labels[contentLocale], href: `${routeBase(type, contentLocale)}/` })),
315
+ ]));
316
+ const localizedPaths = locales.length > 1
317
+ ? [
318
+ Object.fromEntries(locales.map((contentLocale) => [
319
+ contentLocale, contentLocale === locale ? '/' : `/${contentLocale}/`,
320
+ ])),
321
+ ...composition.contentTypes.map((type) => Object.fromEntries(locales.map((contentLocale) => [
322
+ contentLocale, `${routeBase(type, contentLocale)}/`,
323
+ ]))),
324
+ ]
325
+ : [];
174
326
  const files = contentFiles(composition, options);
175
327
  const contributions = files
176
328
  .filter(({ path }) => !path.startsWith('src/pages/'))
177
329
  .map(({ path }, index) => ({ kind: path === 'package.json' ? 'dependency' : 'file', id: `content.file.${index}`, target: path }));
178
330
  for (const type of composition.contentTypes) {
179
- contributions.push({ kind: 'content', id: `content.type.${type.id}`, target: type.primary ? 'primary' : 'additional' }, { kind: 'route', id: `content.list.${type.id}`, target: `${routeBase(type, locale)}/` }, { kind: 'route', id: `content.detail.${type.id}`, target: `${routeBase(type, locale)}/[slug]` }, ...type.bindings.map((binding) => ({ kind: 'binding', id: `content.binding.${type.id}.${binding}`, target: `content.type.${type.id}` })));
331
+ contributions.push({ kind: 'content', id: `content.type.${type.id}`, target: type.primary ? 'primary' : 'additional' }, ...locales.flatMap((contentLocale) => [
332
+ { kind: 'route', id: `content.list.${type.id}.${contentLocale}`, target: `${routeBase(type, contentLocale)}/` },
333
+ { kind: 'route', id: `content.detail.${type.id}.${contentLocale}`, target: `${routeBase(type, contentLocale)}/[slug]` },
334
+ ]), ...type.bindings.map((binding) => ({ kind: 'binding', id: `content.binding.${type.id}.${binding}`, target: `content.type.${type.id}` })));
180
335
  }
181
- const navigation = composition.contentTypes.filter((type) => type.bindings.includes('navigation'))
182
- .map((type) => ({ label: type.labels[locale], href: `${routeBase(type, locale)}/` }));
336
+ const shellOutputContributions = locales.length > 1
337
+ ? [
338
+ ...shellRecipe.outputContributions,
339
+ ...locales.slice(1).map((contentLocale) => ({
340
+ kind: 'route', id: `shell.home.${contentLocale}`, target: `/${contentLocale}/`,
341
+ })),
342
+ ]
343
+ : shellRecipe.outputContributions;
183
344
  return {
184
345
  shell: {
185
346
  ...shellRecipe,
347
+ outputContributions: shellOutputContributions,
186
348
  validators: [{
187
349
  id: 'shell.content-locale', phase: 'options',
188
- validate: ({ options }) => options.defaultLocale === locale ? [] : [{ code: 'CONTENT_LOCALE_MISMATCH', message: 'shell.defaultLocale must match the content composition locale' }],
350
+ validate: ({ options: shellOptions }) => shellOptions.defaultLocale === locale ? [] : [{ code: 'CONTENT_LOCALE_MISMATCH', message: 'shell.defaultLocale must match the content composition locale' }],
189
351
  }],
190
- generate: ({ options: shellOptions }) => ({ files: buildShellFiles(shellOptions, navigation, options.shellConfiguration) }),
352
+ generate: ({ options: shellOptions }) => ({
353
+ files: buildShellFiles(shellOptions, navigationByLocale[locale], {
354
+ ...options.shellConfiguration,
355
+ ...(locales.length > 1 ? { contentLocales: locales, navigationByLocale, localizedPaths } : {}),
356
+ }),
357
+ }),
191
358
  },
192
359
  content: {
193
360
  id: 'content.pages', version: '1.7.1', protocolVersion: 1,
194
- compatibleCliRange: '^0.1.0 || ^0.2.0', compatibleRuntimeRange: contentRuntimeRange,
361
+ compatibleCliRange: '^0.1.0 || ^0.2.0 || ^0.3.0', compatibleRuntimeRange: runtimeRange,
195
362
  provides: ['content.pages', 'content.typed-definitions'], requires: ['site.shell'], conflicts: [],
196
363
  order: { priority: 10, key: 'content' }, optionsSchema: z.strictObject({}),
197
364
  outputContributions: contributions, validators: [],