@easy-web/core 1.9.0 → 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 +27 -3
  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 +213 -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 +91 -2
  39. package/src/recipes/__tests__/shell-recipe.test.ts +31 -0
  40. package/src/recipes/content-site.ts +216 -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
@@ -137,4 +152,13 @@ single configuration renderer. These are package-owned source expressions, not
137
152
  user-configurable JavaScript or a post-generation config merge.
138
153
  Application-auth composition remains unsupported.
139
154
 
155
+ Generated content sites require core `^1.6.0`, the first release with the trait
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`.
163
+
140
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,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,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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;;;mBAAiD,CAAC;AACrF,eAAO,MAAM,mBAAmB;;;mBAA8C,C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().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,iBAAiB;IACtB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG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AA+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;AAMtE,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;AAyIH,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,16 +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
+ 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
+ }
7
13
  export const generatedContentCompositionSchema = contentCompositionSchema.superRefine((composition, context) => {
8
- if (composition.contentLocales.length !== 1) {
9
- 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' });
10
18
  }
11
19
  if (!composition.contentTypes.length) {
12
20
  context.addIssue({ code: 'custom', path: ['contentTypes'], message: 'Content generation requires at least one content type' });
13
21
  }
14
22
  const routes = [];
23
+ const localeRoots = new Set(locales.slice(1).map((locale) => `/${locale}`));
15
24
  composition.contentTypes.forEach((type, index) => {
16
25
  const path = ['contentTypes', index];
17
26
  for (const trait of type.traits) {
@@ -31,7 +40,10 @@ export const generatedContentCompositionSchema = contentCompositionSchema.superR
31
40
  || defaultReservedContentRoutes.some((reserved) => reserved !== '/' && `${base}/`.startsWith(reserved))) {
32
41
  context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Unsupported generated content route "${route}"; use non-reserved lowercase path segments` });
33
42
  }
34
- 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}/`))) {
35
47
  context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Generated list/detail routes overlap at "${route}"` });
36
48
  }
37
49
  routes.push(base);
@@ -41,52 +53,104 @@ export const generatedContentCompositionSchema = contentCompositionSchema.superR
41
53
  function routeBase(type, locale) {
42
54
  return type.routes[locale].replace(/\/$/, '');
43
55
  }
44
- function collectionSchema(type) {
56
+ function collectionSchema(type, locales) {
45
57
  const shapes = ['...titleTraitSchema.unwrap().shape', '...slugTraitSchema.unwrap().shape'];
46
58
  if (type.traits.includes('summary'))
47
59
  shapes.push('...summaryTraitSchema.unwrap().shape');
48
60
  if (type.traits.includes('image')) {
49
61
  shapes.push('image: imageTraitSchema.unwrap().shape.image.unwrap().extend({ src: image() })');
50
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');
51
69
  // File-based IDs keep duplicate public slugs visible to route validation.
52
70
  return `${JSON.stringify(type.id)}: defineCollection({
53
71
  loader: glob({ pattern: '**/*.md', base: ${JSON.stringify(`./src/content/${type.id}`)}, generateId: ({ entry }) => entry.replace(/\\.md$/, '') }),
54
72
  schema: ${type.traits.includes('image') ? '({ image }) => ' : ''}z.object({ ${shapes.join(', ')} }).strict(),
55
73
  })`;
56
74
  }
57
- function adapterSource(type, locale, index) {
58
- 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;
59
86
  return `import type { CollectionEntry } from 'astro:content';
60
87
  import { assertImplements, type Item, type Linkable, ${contracts.map((name) => `type ${name}`).join(', ')} } from '@easy-web/core/contracts';
61
88
  import { composition } from '../../content/definitions';
62
89
 
63
90
  type Entry = CollectionEntry<${JSON.stringify(type.id)}>;
64
91
  assertImplements<Entry['data'], ${contracts.join(' & ')}>();
65
-
66
- 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 {
67
94
  const data = entry.data;
68
95
  return {
69
96
  title: data.title,
70
97
  ${type.traits.includes('summary') ? 'description: data.summary,' : ''}
71
98
  ${type.traits.includes('image') ? 'image: data.image,' : ''}
72
- 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 + '/',
73
100
  };
74
101
  }
75
102
  `;
76
103
  }
77
- function listSource(type, locale) {
104
+ function listSource(type, locale, composition) {
78
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)`;
79
139
  return `---
80
140
  import { getCollection } from 'astro:content';
81
141
  import Base from '${prefix}layouts/Base.astro';
82
142
  import { toItem } from '${prefix}lib/content/${type.id}';
143
+ ${type.traits.includes('order') ? "import { compareContentOrder } from '@easy-web/core/contracts';" : ''}
83
144
  import Card from '@easy-web/core/components/Card.astro';
84
145
  import CardGrid from '@easy-web/core/components/CardGrid.astro';
146
+ ${localized ? "import { getAlternateLinks, ambientTrailingSlash } from '@easy-web/core/i18n';" : ''}
85
147
 
86
- const items = (await getCollection(${JSON.stringify(type.id)}))
87
- .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}
88
152
  ---
89
- <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}` : ''}>
90
154
  <h1>{${JSON.stringify(type.labels[locale])}}</h1>
91
155
  <CardGrid>
92
156
  {items.map((item) => <Card item={item} />)}
@@ -94,32 +158,84 @@ const items = (await getCollection(${JSON.stringify(type.id)}))
94
158
  </Base>
95
159
  `;
96
160
  }
97
- function detailSource(type, locale) {
161
+ function detailSource(type, locale, composition) {
98
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)}` : '';
99
192
  return `---
100
193
  import { getCollection, render, type CollectionEntry } from 'astro:content';
101
194
  import type { Rendered, Item, Linkable } from '@easy-web/core/contracts';
102
195
  import Base from '${prefix}layouts/Base.astro';
103
196
  import { toItem } from '${prefix}lib/content/${type.id}';
104
197
  import Prose from '@easy-web/core/components/Prose.astro';
198
+ ${localized ? "import { getAlternateLinks, ambientTrailingSlash } from '@easy-web/core/i18n';" : ''}
105
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 };
106
202
 
107
- export async function getStaticPaths() {
108
- 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'};
109
206
  const seen = new Set<string>();
207
+ ${localizedSetup}
110
208
  return entries.map((entry) => {
111
209
  if (seen.has(entry.data.slug)) throw new Error('Duplicate content slug: ' + entry.data.slug);
112
210
  seen.add(entry.data.slug);
113
- return { params: { slug: entry.data.slug }, props: { entry } };
114
- });
211
+ ${localizedMap} });
115
212
  }
116
213
 
117
- interface Props { entry: CollectionEntry<${JSON.stringify(type.id)}> }
118
- const { entry } = Astro.props;
119
- 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)) };
120
236
  const { Content } = rendered;
121
237
  ---
122
- <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)}' : ''}>
123
239
  <Prose>
124
240
  <h1>{rendered.title}</h1>
125
241
  {rendered.description && <p>{rendered.description}</p>}
@@ -130,64 +246,119 @@ const { Content } = rendered;
130
246
  `;
131
247
  }
132
248
  function contentFiles(composition, options) {
133
- const locale = composition.contentLocales[0];
249
+ const locales = composition.contentLocales;
250
+ const localized = locales.length > 1;
251
+ const runtimeRange = contentRuntimeFor(composition);
134
252
  const mediaFolder = z.string().regex(/^src\/assets(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/)
135
253
  .parse(options.mediaFolder ?? 'src/assets');
136
254
  const exampleImage = `${mediaFolder}/content-example.svg`;
137
255
  const files = [
138
256
  { path: 'src/content/definitions.ts', content: `import { defineCollection, z } from 'astro:content';
139
257
  import { glob } from 'astro/loaders';
140
- 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';
141
259
 
142
260
  export const composition = ${JSON.stringify(composition, null, 2)} as const;
143
261
 
144
262
  export const collections = {
145
- ${composition.contentTypes.map(collectionSchema).join(',\n ')},
263
+ ${composition.contentTypes.map((type) => collectionSchema(type, locales)).join(',\n ')},
146
264
  };
147
265
  ` },
148
266
  { path: 'src/content.config.ts', content: "export { collections } from './content/definitions';\n" },
267
+ { path: 'package.json', content: `${JSON.stringify({ dependencies: {
268
+ '@easy-web/core': runtimeRange,
269
+ ...(composition.contentTypes.some((type) => type.traits.includes('image')) ? { sharp: '^0.35.0' } : {}),
270
+ } }, null, 2)}\n` },
149
271
  ];
150
272
  if (composition.contentTypes.some((type) => type.traits.includes('image'))) {
151
- files.push({ path: 'package.json', content: `${JSON.stringify({ dependencies: { sharp: '^0.35.0' } }, null, 2)}\n` });
152
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' });
153
274
  }
154
275
  for (const [index, type] of composition.contentTypes.entries()) {
155
- const data = {
156
- title: `${type.labels[locale]} - ${locale === 'de' ? 'Beispiel' : 'Example'}`,
157
- slug: 'example',
158
- ...(type.traits.includes('summary') ? { summary: locale === 'de' ? 'Generierter Beispielinhalt.' : 'Generated example content.' } : {}),
159
- ...(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' } } : {}),
160
- };
161
- const base = routeBase(type, locale).slice(1);
162
- 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
+ }
163
302
  }
164
303
  return files;
165
304
  }
166
305
  /** Bind package-owned content generation to a validated composition, independently of a CMS. */
167
306
  export function createContentSiteRecipes(rawComposition, options = {}) {
168
307
  const composition = generatedContentCompositionSchema.parse(rawComposition);
169
- 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
+ : [];
170
326
  const files = contentFiles(composition, options);
171
327
  const contributions = files
172
328
  .filter(({ path }) => !path.startsWith('src/pages/'))
173
329
  .map(({ path }, index) => ({ kind: path === 'package.json' ? 'dependency' : 'file', id: `content.file.${index}`, target: path }));
174
330
  for (const type of composition.contentTypes) {
175
- 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}` })));
176
335
  }
177
- const navigation = composition.contentTypes.filter((type) => type.bindings.includes('navigation'))
178
- .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;
179
344
  return {
180
345
  shell: {
181
346
  ...shellRecipe,
347
+ outputContributions: shellOutputContributions,
182
348
  validators: [{
183
349
  id: 'shell.content-locale', phase: 'options',
184
- 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' }],
185
351
  }],
186
- 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
+ }),
187
358
  },
188
359
  content: {
189
360
  id: 'content.pages', version: '1.7.1', protocolVersion: 1,
190
- compatibleCliRange: '^0.1.0 || ^0.2.0', compatibleRuntimeRange: '^1.7.1',
361
+ compatibleCliRange: '^0.1.0 || ^0.2.0 || ^0.3.0', compatibleRuntimeRange: runtimeRange,
191
362
  provides: ['content.pages', 'content.typed-definitions'], requires: ['site.shell'], conflicts: [],
192
363
  order: { priority: 10, key: 'content' }, optionsSchema: z.strictObject({}),
193
364
  outputContributions: contributions, validators: [],