@easy-web/core 1.8.0 → 1.9.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.
- package/README.md +23 -1
- package/dist/recipes/content-site.d.ts +75 -0
- package/dist/recipes/content-site.d.ts.map +1 -0
- package/dist/recipes/content-site.js +198 -0
- package/dist/recipes/content-site.js.map +1 -0
- package/dist/recipes/index.d.ts +1 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +1 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/recipes/shell-recipe.d.ts +8 -1
- package/dist/recipes/shell-recipe.d.ts.map +1 -1
- package/dist/recipes/shell-recipe.js +21 -16
- package/dist/recipes/shell-recipe.js.map +1 -1
- package/package.json +1 -1
- package/src/recipes/__tests__/content-site.test.ts +66 -0
- package/src/recipes/__tests__/shell-recipe.test.ts +3 -1
- package/src/recipes/content-site.ts +225 -0
- package/src/recipes/index.ts +1 -0
- package/src/recipes/shell-recipe.ts +29 -17
package/README.md
CHANGED
|
@@ -99,7 +99,9 @@ are allowed. A registry pin identifies package name, exact version, SHA-512 SRI
|
|
|
99
99
|
and package-relative export path. The future loader must verify artifact bytes
|
|
100
100
|
before importing executable code; admission checks its receipt against the
|
|
101
101
|
CLI-owned registry, not a registry supplied by the target. A receipt schema alone
|
|
102
|
-
is not cryptographic verification.
|
|
102
|
+
is not cryptographic verification. The verified-artifact loader is not implemented;
|
|
103
|
+
the CLI currently imports its first-party workspace/package dependencies directly.
|
|
104
|
+
Core ships the shell recipe and content-site recipe factory.
|
|
103
105
|
|
|
104
106
|
## Generic content composition
|
|
105
107
|
|
|
@@ -115,4 +117,24 @@ Only a money-enabled selection accepts `currency`, validated by the shared ISO
|
|
|
115
117
|
4217 input schema. `homepage` requires `featured`, so a type cannot occupy that
|
|
116
118
|
featured presentation slot merely by defining an image.
|
|
117
119
|
|
|
120
|
+
`createContentSiteRecipes(composition)` from `@easy-web/core/recipes` connects a
|
|
121
|
+
validated composition to shell navigation and a `content.pages` recipe. Its
|
|
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
|
|
125
|
+
contract selections fail with an explicit not-yet-supported diagnostic.
|
|
126
|
+
|
|
127
|
+
The recipe generates Astro collections from shared trait schemas, deterministic
|
|
128
|
+
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
|
+
roles and bindings are logical graph contributions, not output filenames.
|
|
131
|
+
`primary` is a graph role; it does not select a homepage automatically.
|
|
132
|
+
`@easy-web/cms-adapters` supplies `createCmsContentSiteRecipes` for the CMS-enabled
|
|
133
|
+
path, consuming the same composition without replacing core's schemas or routes.
|
|
134
|
+
Core's optional `ContentSiteOptions` lets first-party recipes choose an asset
|
|
135
|
+
folder and contribute imports/integrations/markdown processing to the shell's
|
|
136
|
+
single configuration renderer. These are package-owned source expressions, not
|
|
137
|
+
user-configurable JavaScript or a post-generation config merge.
|
|
138
|
+
Application-auth composition remains unsupported.
|
|
139
|
+
|
|
118
140
|
This package is published as part of the fixed `@easy-web/*` family through the Changesets and npm Trusted Publishing workflow.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import type { ShellConfiguration, ShellRecipeOptions } from './shell-recipe.js';
|
|
3
|
+
import type { RecipeMetadata } from './types.js';
|
|
4
|
+
export interface ContentSiteOptions {
|
|
5
|
+
readonly mediaFolder?: string;
|
|
6
|
+
readonly shellConfiguration?: ShellConfiguration;
|
|
7
|
+
}
|
|
8
|
+
export declare const generatedContentCompositionSchema: z.ZodReadonly<z.ZodObject<{
|
|
9
|
+
contentLocales: z.ZodReadonly<z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentLocale", "out">>>;
|
|
10
|
+
contentTypes: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
11
|
+
traits: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
12
|
+
title: "title";
|
|
13
|
+
slug: "slug";
|
|
14
|
+
summary: "summary";
|
|
15
|
+
body: "body";
|
|
16
|
+
image: "image";
|
|
17
|
+
photos: "photos";
|
|
18
|
+
order: "order";
|
|
19
|
+
taxonomy: "taxonomy";
|
|
20
|
+
publication: "publication";
|
|
21
|
+
schedule: "schedule";
|
|
22
|
+
location: "location";
|
|
23
|
+
cta: "cta";
|
|
24
|
+
money: "money";
|
|
25
|
+
featured: "featured";
|
|
26
|
+
}>>>;
|
|
27
|
+
currency: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "CurrencyCode", "out">>;
|
|
28
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentTypeId", "out">;
|
|
29
|
+
primary: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
labels: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
31
|
+
routes: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
32
|
+
bindings: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
33
|
+
homepage: "homepage";
|
|
34
|
+
list: "list";
|
|
35
|
+
detail: "detail";
|
|
36
|
+
navigation: "navigation";
|
|
37
|
+
"cms-admin": "cms-admin";
|
|
38
|
+
}>>>;
|
|
39
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
40
|
+
traits: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
41
|
+
title: "title";
|
|
42
|
+
slug: "slug";
|
|
43
|
+
summary: "summary";
|
|
44
|
+
body: "body";
|
|
45
|
+
image: "image";
|
|
46
|
+
photos: "photos";
|
|
47
|
+
order: "order";
|
|
48
|
+
taxonomy: "taxonomy";
|
|
49
|
+
publication: "publication";
|
|
50
|
+
schedule: "schedule";
|
|
51
|
+
location: "location";
|
|
52
|
+
cta: "cta";
|
|
53
|
+
money: "money";
|
|
54
|
+
featured: "featured";
|
|
55
|
+
}>>>;
|
|
56
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentTypeId", "out">;
|
|
57
|
+
primary: z.ZodDefault<z.ZodBoolean>;
|
|
58
|
+
labels: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
59
|
+
routes: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
60
|
+
bindings: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
61
|
+
homepage: "homepage";
|
|
62
|
+
list: "list";
|
|
63
|
+
detail: "detail";
|
|
64
|
+
navigation: "navigation";
|
|
65
|
+
"cms-admin": "cms-admin";
|
|
66
|
+
}>>>;
|
|
67
|
+
}, z.core.$strict>>]>>>;
|
|
68
|
+
reservedRoutes: z.ZodReadonly<z.ZodDefault<z.ZodArray<z.ZodString>>>;
|
|
69
|
+
}, z.core.$strict>>;
|
|
70
|
+
/** Bind package-owned content generation to a validated composition, independently of a CMS. */
|
|
71
|
+
export declare function createContentSiteRecipes(rawComposition: unknown, options?: ContentSiteOptions): {
|
|
72
|
+
readonly shell: RecipeMetadata<ShellRecipeOptions>;
|
|
73
|
+
readonly content: RecipeMetadata;
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=content-site.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { posix } from 'node:path';
|
|
3
|
+
import { contentCompositionSchema, defaultReservedContentRoutes } from '../contracts/content-composition.js';
|
|
4
|
+
import { buildShellFiles, shellRecipe } from './shell-recipe.js';
|
|
5
|
+
const supportedTraits = new Set(['title', 'slug', 'summary', 'image', 'body']);
|
|
6
|
+
const supportedBindings = new Set(['list', 'detail', 'navigation', 'cms-admin']);
|
|
7
|
+
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' });
|
|
10
|
+
}
|
|
11
|
+
if (!composition.contentTypes.length) {
|
|
12
|
+
context.addIssue({ code: 'custom', path: ['contentTypes'], message: 'Content generation requires at least one content type' });
|
|
13
|
+
}
|
|
14
|
+
const routes = [];
|
|
15
|
+
composition.contentTypes.forEach((type, index) => {
|
|
16
|
+
const path = ['contentTypes', index];
|
|
17
|
+
for (const trait of type.traits) {
|
|
18
|
+
if (!supportedTraits.has(trait))
|
|
19
|
+
context.addIssue({ code: 'custom', path: [...path, 'traits'], message: `Content generation does not yet support trait "${trait}"` });
|
|
20
|
+
}
|
|
21
|
+
for (const binding of type.bindings) {
|
|
22
|
+
if (!supportedBindings.has(binding))
|
|
23
|
+
context.addIssue({ code: 'custom', path: [...path, 'bindings'], message: `Content generation does not yet support binding "${binding}"` });
|
|
24
|
+
}
|
|
25
|
+
if (!type.bindings.includes('list') || !type.bindings.includes('detail')) {
|
|
26
|
+
context.addIssue({ code: 'custom', path: [...path, 'bindings'], message: 'Content generation requires both list and detail bindings' });
|
|
27
|
+
}
|
|
28
|
+
for (const route of Object.values(type.routes)) {
|
|
29
|
+
const base = route.replace(/\/$/, '');
|
|
30
|
+
if (!/^\/[a-z0-9]+(?:-[a-z0-9]+)*(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/.test(base)
|
|
31
|
+
|| defaultReservedContentRoutes.some((reserved) => reserved !== '/' && `${base}/`.startsWith(reserved))) {
|
|
32
|
+
context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Unsupported generated content route "${route}"; use non-reserved lowercase path segments` });
|
|
33
|
+
}
|
|
34
|
+
if (routes.some((other) => base.startsWith(`${other}/`) || other.startsWith(`${base}/`))) {
|
|
35
|
+
context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Generated list/detail routes overlap at "${route}"` });
|
|
36
|
+
}
|
|
37
|
+
routes.push(base);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
function routeBase(type, locale) {
|
|
42
|
+
return type.routes[locale].replace(/\/$/, '');
|
|
43
|
+
}
|
|
44
|
+
function collectionSchema(type) {
|
|
45
|
+
const shapes = ['...titleTraitSchema.unwrap().shape', '...slugTraitSchema.unwrap().shape'];
|
|
46
|
+
if (type.traits.includes('summary'))
|
|
47
|
+
shapes.push('...summaryTraitSchema.unwrap().shape');
|
|
48
|
+
if (type.traits.includes('image')) {
|
|
49
|
+
shapes.push('image: imageTraitSchema.unwrap().shape.image.unwrap().extend({ src: image() })');
|
|
50
|
+
}
|
|
51
|
+
// File-based IDs keep duplicate public slugs visible to route validation.
|
|
52
|
+
return `${JSON.stringify(type.id)}: defineCollection({
|
|
53
|
+
loader: glob({ pattern: '**/*.md', base: ${JSON.stringify(`./src/content/${type.id}`)}, generateId: ({ entry }) => entry.replace(/\\.md$/, '') }),
|
|
54
|
+
schema: ${type.traits.includes('image') ? '({ image }) => ' : ''}z.object({ ${shapes.join(', ')} }).strict(),
|
|
55
|
+
})`;
|
|
56
|
+
}
|
|
57
|
+
function adapterSource(type, locale, index) {
|
|
58
|
+
const contracts = ['HasTitle', 'HasSlug', ...(type.traits.includes('summary') ? ['HasSummary'] : []), ...(type.traits.includes('image') ? ['HasImage'] : [])];
|
|
59
|
+
return `import type { CollectionEntry } from 'astro:content';
|
|
60
|
+
import { assertImplements, type Item, type Linkable, ${contracts.map((name) => `type ${name}`).join(', ')} } from '@easy-web/core/contracts';
|
|
61
|
+
import { composition } from '../../content/definitions';
|
|
62
|
+
|
|
63
|
+
type Entry = CollectionEntry<${JSON.stringify(type.id)}>;
|
|
64
|
+
assertImplements<Entry['data'], ${contracts.join(' & ')}>();
|
|
65
|
+
|
|
66
|
+
export function toItem(entry: Entry): Item & Linkable {
|
|
67
|
+
const data = entry.data;
|
|
68
|
+
return {
|
|
69
|
+
title: data.title,
|
|
70
|
+
${type.traits.includes('summary') ? 'description: data.summary,' : ''}
|
|
71
|
+
${type.traits.includes('image') ? 'image: data.image,' : ''}
|
|
72
|
+
href: composition.contentTypes[${index}].routes[${JSON.stringify(locale)}].replace(/\\/$/, '') + '/' + data.slug + '/',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
function listSource(type, locale) {
|
|
78
|
+
const prefix = '../'.repeat(routeBase(type, locale).split('/').length);
|
|
79
|
+
return `---
|
|
80
|
+
import { getCollection } from 'astro:content';
|
|
81
|
+
import Base from '${prefix}layouts/Base.astro';
|
|
82
|
+
import { toItem } from '${prefix}lib/content/${type.id}';
|
|
83
|
+
import Card from '@easy-web/core/components/Card.astro';
|
|
84
|
+
import CardGrid from '@easy-web/core/components/CardGrid.astro';
|
|
85
|
+
|
|
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);
|
|
88
|
+
---
|
|
89
|
+
<Base title={${JSON.stringify(type.labels[locale])}}>
|
|
90
|
+
<h1>{${JSON.stringify(type.labels[locale])}}</h1>
|
|
91
|
+
<CardGrid>
|
|
92
|
+
{items.map((item) => <Card item={item} />)}
|
|
93
|
+
</CardGrid>
|
|
94
|
+
</Base>
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
function detailSource(type, locale) {
|
|
98
|
+
const prefix = '../'.repeat(routeBase(type, locale).split('/').length);
|
|
99
|
+
return `---
|
|
100
|
+
import { getCollection, render, type CollectionEntry } from 'astro:content';
|
|
101
|
+
import type { Rendered, Item, Linkable } from '@easy-web/core/contracts';
|
|
102
|
+
import Base from '${prefix}layouts/Base.astro';
|
|
103
|
+
import { toItem } from '${prefix}lib/content/${type.id}';
|
|
104
|
+
import Prose from '@easy-web/core/components/Prose.astro';
|
|
105
|
+
${type.traits.includes('image') ? "import Media from '@easy-web/core/components/Media.astro';" : ''}
|
|
106
|
+
|
|
107
|
+
export async function getStaticPaths() {
|
|
108
|
+
const entries = await getCollection(${JSON.stringify(type.id)});
|
|
109
|
+
const seen = new Set<string>();
|
|
110
|
+
return entries.map((entry) => {
|
|
111
|
+
if (seen.has(entry.data.slug)) throw new Error('Duplicate content slug: ' + entry.data.slug);
|
|
112
|
+
seen.add(entry.data.slug);
|
|
113
|
+
return { params: { slug: entry.data.slug }, props: { entry } };
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
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)) };
|
|
120
|
+
const { Content } = rendered;
|
|
121
|
+
---
|
|
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)}' : ''}>
|
|
123
|
+
<Prose>
|
|
124
|
+
<h1>{rendered.title}</h1>
|
|
125
|
+
{rendered.description && <p>{rendered.description}</p>}
|
|
126
|
+
${type.traits.includes('image') ? '{rendered.image && <Media image={rendered.image} />}' : ''}
|
|
127
|
+
<Content />
|
|
128
|
+
</Prose>
|
|
129
|
+
</Base>
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
function contentFiles(composition, options) {
|
|
133
|
+
const locale = composition.contentLocales[0];
|
|
134
|
+
const mediaFolder = z.string().regex(/^src\/assets(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/)
|
|
135
|
+
.parse(options.mediaFolder ?? 'src/assets');
|
|
136
|
+
const exampleImage = `${mediaFolder}/content-example.svg`;
|
|
137
|
+
const files = [
|
|
138
|
+
{ path: 'src/content/definitions.ts', content: `import { defineCollection, z } from 'astro:content';
|
|
139
|
+
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';
|
|
141
|
+
|
|
142
|
+
export const composition = ${JSON.stringify(composition, null, 2)} as const;
|
|
143
|
+
|
|
144
|
+
export const collections = {
|
|
145
|
+
${composition.contentTypes.map(collectionSchema).join(',\n ')},
|
|
146
|
+
};
|
|
147
|
+
` },
|
|
148
|
+
{ path: 'src/content.config.ts', content: "export { collections } from './content/definitions';\n" },
|
|
149
|
+
];
|
|
150
|
+
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
|
+
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
|
+
}
|
|
154
|
+
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) });
|
|
163
|
+
}
|
|
164
|
+
return files;
|
|
165
|
+
}
|
|
166
|
+
/** Bind package-owned content generation to a validated composition, independently of a CMS. */
|
|
167
|
+
export function createContentSiteRecipes(rawComposition, options = {}) {
|
|
168
|
+
const composition = generatedContentCompositionSchema.parse(rawComposition);
|
|
169
|
+
const locale = composition.contentLocales[0];
|
|
170
|
+
const files = contentFiles(composition, options);
|
|
171
|
+
const contributions = files
|
|
172
|
+
.filter(({ path }) => !path.startsWith('src/pages/'))
|
|
173
|
+
.map(({ path }, index) => ({ kind: path === 'package.json' ? 'dependency' : 'file', id: `content.file.${index}`, target: path }));
|
|
174
|
+
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}` })));
|
|
176
|
+
}
|
|
177
|
+
const navigation = composition.contentTypes.filter((type) => type.bindings.includes('navigation'))
|
|
178
|
+
.map((type) => ({ label: type.labels[locale], href: `${routeBase(type, locale)}/` }));
|
|
179
|
+
return {
|
|
180
|
+
shell: {
|
|
181
|
+
...shellRecipe,
|
|
182
|
+
validators: [{
|
|
183
|
+
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' }],
|
|
185
|
+
}],
|
|
186
|
+
generate: ({ options: shellOptions }) => ({ files: buildShellFiles(shellOptions, navigation, options.shellConfiguration) }),
|
|
187
|
+
},
|
|
188
|
+
content: {
|
|
189
|
+
id: 'content.pages', version: '1.7.1', protocolVersion: 1,
|
|
190
|
+
compatibleCliRange: '^0.1.0 || ^0.2.0', compatibleRuntimeRange: '^1.7.1',
|
|
191
|
+
provides: ['content.pages', 'content.typed-definitions'], requires: ['site.shell'], conflicts: [],
|
|
192
|
+
order: { priority: 10, key: 'content' }, optionsSchema: z.strictObject({}),
|
|
193
|
+
outputContributions: contributions, validators: [],
|
|
194
|
+
generate: () => ({ files }),
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=content-site.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-site.js","sourceRoot":"","sources":["../../src/recipes/content-site.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,O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MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,+DAA+D,EAAE,CAAC;iBACrL,CAAC;YACF,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;SAC9H;QACD,OAAO,EAAE;YACL,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;YACzD,kBAAkB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,QAAQ;YACxE,QAAQ,EAAE,CAAC,eAAe,EAAE,2BAA2B,CAAC,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE;YACjG,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC;YAC1E,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAE,EAAE;YAClD,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;SAC9B;KACJ,CAAC;AACN,CAAC"}
|
package/dist/recipes/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/recipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/recipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
package/dist/recipes/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'astro/zod';
|
|
2
|
+
import type { NavItem } from '../contracts/types.js';
|
|
2
3
|
export declare const SHELL_RECIPE_ID = "site.shell";
|
|
3
4
|
declare const shellOptionsSchema: z.ZodObject<{
|
|
4
5
|
siteName: z.ZodDefault<z.ZodString>;
|
|
@@ -6,7 +7,13 @@ declare const shellOptionsSchema: z.ZodObject<{
|
|
|
6
7
|
noIndex: z.ZodDefault<z.ZodBoolean>;
|
|
7
8
|
}, z.core.$strict>;
|
|
8
9
|
export type ShellRecipeOptions = z.infer<typeof shellOptionsSchema>;
|
|
9
|
-
|
|
10
|
+
/** Source expressions supplied by first-party recipes, never by CLI configuration. */
|
|
11
|
+
export interface ShellConfiguration {
|
|
12
|
+
readonly imports?: readonly string[];
|
|
13
|
+
readonly integrations?: readonly string[];
|
|
14
|
+
readonly markdownProcessor?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function buildShellFiles(rawOptions: unknown, navigation?: readonly NavItem[], configuration?: ShellConfiguration): readonly {
|
|
10
17
|
path: string;
|
|
11
18
|
content: string;
|
|
12
19
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-recipe.d.ts","sourceRoot":"","sources":["../../src/recipes/shell-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"shell-recipe.d.ts","sourceRoot":"","sources":["../../src/recipes/shell-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C,QAAA,MAAM,kBAAkB;;;;kBAItB,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE,sFAAsF;AACtF,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACvC;AA+GD,wBAAgB,eAAe,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,GAAE,SAAS,OAAO,EAAO,EAAE,aAAa,GAAE,kBAAuB,GAAG,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAa9K;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuBA;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;;kBAtCuG,MAAM;qBAAW,MAAM;;;CAuC7H,CAAC;AAE/C,eAAe,WAAW,CAAC"}
|
|
@@ -6,48 +6,56 @@ const shellOptionsSchema = z.strictObject({
|
|
|
6
6
|
noIndex: z.boolean().default(false),
|
|
7
7
|
});
|
|
8
8
|
const PLACEHOLDER_SITE_URL = 'https://replace-with-your-domain.example';
|
|
9
|
-
function astroConfig(options) {
|
|
9
|
+
function astroConfig(options, configuration) {
|
|
10
10
|
return `import { defineConfig } from 'astro/config';
|
|
11
11
|
import easyWebSeo from '@easy-web/core/seo';
|
|
12
|
+
${(configuration.imports ?? []).join('\n')}
|
|
12
13
|
|
|
13
14
|
export default defineConfig({
|
|
14
15
|
site: ${JSON.stringify(PLACEHOLDER_SITE_URL)},
|
|
16
|
+
${configuration.markdownProcessor ? `markdown: { processor: ${configuration.markdownProcessor} },` : ''}
|
|
15
17
|
integrations: [
|
|
16
18
|
easyWebSeo({ noIndex: ${options.noIndex ? 'true' : 'false'} }),
|
|
19
|
+
${(configuration.integrations ?? []).map((integration) => `${integration},`).join('\n ')}
|
|
17
20
|
],
|
|
18
21
|
});
|
|
19
22
|
`;
|
|
20
23
|
}
|
|
21
24
|
const packageJsonFragment = `${JSON.stringify({
|
|
22
25
|
type: 'module',
|
|
23
|
-
scripts: { dev: 'astro dev', build: 'astro build', preview: 'astro preview' },
|
|
26
|
+
scripts: { dev: 'astro dev', typecheck: 'astro check', build: 'astro build', preview: 'astro preview' },
|
|
24
27
|
dependencies: { '@easy-web/core': '^1.5.0', astro: '^7.3.5' },
|
|
25
|
-
devDependencies: { typescript: '^5.5.0' },
|
|
28
|
+
devDependencies: { '@astrojs/check': '^0.9.4', typescript: '^5.5.0' },
|
|
26
29
|
}, null, 2)}\n`;
|
|
27
30
|
const pnpmWorkspace = `allowBuilds:
|
|
28
31
|
esbuild: true
|
|
29
32
|
sharp: true
|
|
30
33
|
`;
|
|
31
|
-
function baseLayout(options) {
|
|
34
|
+
function baseLayout(options, navigation) {
|
|
32
35
|
return `---
|
|
33
36
|
import PageShell from '@easy-web/core/components/PageShell.astro';
|
|
34
37
|
import Header from '@easy-web/core/components/Header.astro';
|
|
35
38
|
import Footer from '@easy-web/core/components/Footer.astro';
|
|
39
|
+
import SeoHead from '@easy-web/core/components/SeoHead.astro';
|
|
40
|
+
import '@easy-web/core/styles/tokens.css';
|
|
36
41
|
|
|
37
42
|
interface Props {
|
|
38
43
|
title: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
image?: string;
|
|
39
46
|
}
|
|
40
|
-
const { title } = Astro.props;
|
|
47
|
+
const { title, description, image } = Astro.props;
|
|
41
48
|
const siteName = ${JSON.stringify(options.siteName)};
|
|
42
49
|
const currentLang = ${JSON.stringify(options.defaultLocale)};
|
|
43
|
-
const navItems = [{ label: 'Home', href: '/' }];
|
|
50
|
+
const navItems = ${JSON.stringify([{ label: options.defaultLocale === 'de' ? 'Startseite' : 'Home', href: '/' }, ...navigation])};
|
|
44
51
|
---
|
|
45
52
|
<!doctype html>
|
|
46
53
|
<html lang=${JSON.stringify(options.defaultLocale)}>
|
|
47
54
|
<head>
|
|
48
55
|
<meta charset="utf-8" />
|
|
49
56
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
50
|
-
<title
|
|
57
|
+
<SeoHead title={title} description={description} ogImage={image}
|
|
58
|
+
pathname={Astro.url.pathname} locale={currentLang} siteName={siteName} />
|
|
51
59
|
</head>
|
|
52
60
|
<body>
|
|
53
61
|
<PageShell lang={currentLang}>
|
|
@@ -95,24 +103,21 @@ const localizedPaths = `import type { LocalizedPathGroup } from '@easy-web/core/
|
|
|
95
103
|
|
|
96
104
|
export const localizedPaths: readonly LocalizedPathGroup[] = [];
|
|
97
105
|
`;
|
|
98
|
-
const robotsTxt = `Disallow: /admin/
|
|
99
|
-
Sitemap: ${PLACEHOLDER_SITE_URL}/sitemap-index.xml
|
|
100
|
-
`;
|
|
101
106
|
const gitignore = `node_modules
|
|
102
107
|
dist
|
|
103
108
|
.astro
|
|
104
109
|
`;
|
|
105
|
-
export function buildShellFiles(rawOptions) {
|
|
110
|
+
export function buildShellFiles(rawOptions, navigation = [], configuration = {}) {
|
|
106
111
|
const options = shellOptionsSchema.parse(rawOptions ?? {});
|
|
107
112
|
return [
|
|
108
|
-
{ path: 'astro.config.mjs', content: astroConfig(options) },
|
|
113
|
+
{ path: 'astro.config.mjs', content: astroConfig(options, configuration) },
|
|
109
114
|
{ path: 'package.json', content: packageJsonFragment },
|
|
110
115
|
{ path: 'pnpm-workspace.yaml', content: pnpmWorkspace },
|
|
111
|
-
{ path: 'src/layouts/Base.astro', content: baseLayout(options) },
|
|
116
|
+
{ path: 'src/layouts/Base.astro', content: baseLayout(options, navigation) },
|
|
112
117
|
{ path: 'src/pages/index.astro', content: homePage(options) },
|
|
113
118
|
{ path: 'src/pages/404.astro', content: notFoundPage(options) },
|
|
114
119
|
{ path: 'src/lib/localized-paths.ts', content: localizedPaths },
|
|
115
|
-
{ path: '
|
|
120
|
+
{ path: 'tsconfig.json', content: `${JSON.stringify({ extends: 'astro/tsconfigs/strict', include: ['.astro/types.d.ts', '**/*'], exclude: ['dist'] }, null, 2)}\n` },
|
|
116
121
|
{ path: '.gitignore', content: gitignore },
|
|
117
122
|
];
|
|
118
123
|
}
|
|
@@ -120,7 +125,7 @@ export const shellRecipe = {
|
|
|
120
125
|
id: SHELL_RECIPE_ID,
|
|
121
126
|
version: '1.5.0',
|
|
122
127
|
protocolVersion: 1,
|
|
123
|
-
compatibleCliRange: '^0.1.0',
|
|
128
|
+
compatibleCliRange: '^0.1.0 || ^0.2.0',
|
|
124
129
|
compatibleRuntimeRange: '^1.5.0',
|
|
125
130
|
provides: [SHELL_RECIPE_ID],
|
|
126
131
|
requires: [],
|
|
@@ -135,7 +140,7 @@ export const shellRecipe = {
|
|
|
135
140
|
{ kind: 'route', id: 'shell.home', target: '/' },
|
|
136
141
|
{ kind: 'route', id: 'shell.404', target: '/404' },
|
|
137
142
|
{ kind: 'file', id: 'shell.localized-paths', target: 'src/lib/localized-paths.ts' },
|
|
138
|
-
{ kind: '
|
|
143
|
+
{ kind: 'configuration', id: 'shell.tsconfig', target: 'tsconfig.json' },
|
|
139
144
|
{ kind: 'file', id: 'shell.gitignore', target: '.gitignore' },
|
|
140
145
|
],
|
|
141
146
|
validators: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-recipe.js","sourceRoot":"","sources":["../../src/recipes/shell-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"shell-recipe.js","sourceRoot":"","sources":["../../src/recipes/shell-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAI9B,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C,MAAM,kBAAkB,GAAG,CAAC,CAAC,YAAY,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IACnD,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACtC,CAAC,CAAC;AAIH,MAAM,oBAAoB,GAAG,0CAA0C,CAAC;AASxE,SAAS,WAAW,CAAC,OAA2B,EAAE,aAAiC;IAC/E,OAAO;;EAET,CAAC,aAAa,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,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I,EAAE,MAAM,EAAE,EAAE,EAAE,uBAAuB,EAAE,MAAM,EAAE,4BAA4B,EAAE;QACnF,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE,eAAe,EAAE;QACxE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,EAAE;KAChE;IACD,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,CAAC,OAA8B,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;CACjD,CAAC;AAE/C,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { createContentSiteRecipes, generatedContentCompositionSchema } from '../content-site.js';
|
|
3
|
+
import { resolveCapabilityGraph } from '../graph.js';
|
|
4
|
+
import { shellRecipe } from '../shell-recipe.js';
|
|
5
|
+
|
|
6
|
+
const type = {
|
|
7
|
+
id: 'entries', primary: true, labels: { en: 'Entries' }, routes: { en: '/entries/' },
|
|
8
|
+
traits: ['title', 'slug', 'summary', 'image', 'body'],
|
|
9
|
+
bindings: ['list', 'detail', 'navigation'],
|
|
10
|
+
};
|
|
11
|
+
const composition = { contentLocales: ['en'], contentTypes: [type] };
|
|
12
|
+
|
|
13
|
+
describe('content site recipes', () => {
|
|
14
|
+
it('resolves content roles, rendering bindings and routes with shell navigation', async () => {
|
|
15
|
+
const recipes = createContentSiteRecipes(composition);
|
|
16
|
+
const graph = resolveCapabilityGraph([recipes.content, recipes.shell]);
|
|
17
|
+
expect(graph.ok).toBe(true);
|
|
18
|
+
if (!graph.ok) throw new Error(JSON.stringify(graph.error));
|
|
19
|
+
expect(graph.value.contentTypes.primary?.id).toBe('content.type.entries');
|
|
20
|
+
expect(graph.value.contributions.filter(({ kind }) => kind === 'binding')).toHaveLength(3);
|
|
21
|
+
expect(graph.value.fixedPages.map(({ target }) => target)).toEqual(expect.arrayContaining(['/entries/', '/entries/[slug]']));
|
|
22
|
+
const shell = await recipes.shell.generate({ options: shellRecipe.optionsSchema.parse({}), capabilities: [], contributions: [] });
|
|
23
|
+
expect(shell.files.find(({ path }) => path === 'src/layouts/Base.astro')?.content).toContain('"href":"/entries/"');
|
|
24
|
+
const content = await recipes.content.generate({ options: {}, capabilities: [], contributions: [] });
|
|
25
|
+
expect(content.files.find(({ path }) => path === 'src/content/definitions.ts')?.content).toContain('image()');
|
|
26
|
+
expect(content.files.find(({ path }) => path === 'src/lib/content/entries.ts')?.content).toContain("assertImplements<Entry['data'], HasTitle & HasSlug & HasSummary & HasImage>()");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('omits optional image/summary fields and navigation rather than inventing capabilities', async () => {
|
|
30
|
+
const recipes = createContentSiteRecipes({ ...composition, contentTypes: [{ ...type, traits: ['title', 'slug', 'body'], bindings: ['list', 'detail'] }] });
|
|
31
|
+
const content = await recipes.content.generate({ options: {}, capabilities: [], contributions: [] });
|
|
32
|
+
expect(content.files.some(({ path }) => path.endsWith('.svg'))).toBe(false);
|
|
33
|
+
expect(content.files.find(({ path }) => path === 'src/lib/content/entries.ts')?.content).not.toContain('data.summary');
|
|
34
|
+
expect(recipes.content.outputContributions.some(({ id }) => id.endsWith('.navigation'))).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('uses bracket access for kebab-case collection IDs and nested route imports', async () => {
|
|
38
|
+
const recipes = createContentSiteRecipes({ ...composition, contentTypes: [{ ...type, id: 'example-entry', routes: { en: '/library/entries' } }] });
|
|
39
|
+
const content = await recipes.content.generate({ options: {}, capabilities: [], contributions: [] });
|
|
40
|
+
expect(content.files.find(({ path }) => path === 'src/pages/library/entries/index.astro')?.content).toContain("../../../lib/content/example-entry");
|
|
41
|
+
expect(content.files.find(({ path }) => path === 'src/content/definitions.ts')?.content).toContain('"example-entry": defineCollection');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it.each([
|
|
45
|
+
{ traits: ['title', 'slug', 'body', 'photos'] },
|
|
46
|
+
{ traits: ['title', 'slug', 'body', 'money'], currency: 'EUR' },
|
|
47
|
+
{ bindings: ['homepage', 'list', 'detail'], traits: ['title', 'slug', 'image', 'featured', 'body'] },
|
|
48
|
+
{ bindings: ['list'] },
|
|
49
|
+
{ traits: ['title', 'slug'] },
|
|
50
|
+
{ routes: { en: '/admin/imports/' } },
|
|
51
|
+
{ routes: { en: '/404/examples/' } },
|
|
52
|
+
{ routes: { en: '/x/[slug]/' } },
|
|
53
|
+
{ routes: { en: '/x/../y/' } },
|
|
54
|
+
])('rejects unsupported composition changes %j', (change) => {
|
|
55
|
+
expect(generatedContentCompositionSchema.safeParse({ ...composition, reservedRoutes: [], contentTypes: [{ ...type, ...change }] }).success).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('rejects overlapping routes before producing recipes', () => {
|
|
59
|
+
expect(() => createContentSiteRecipes({ ...composition, contentTypes: [type, { ...type, id: 'other', primary: false, routes: { en: '/entries/example/' } }] })).toThrow('overlap');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('rejects multiple locales and empty content selections', () => {
|
|
63
|
+
expect(generatedContentCompositionSchema.safeParse({ contentLocales: ['en'], contentTypes: [] }).success).toBe(false);
|
|
64
|
+
expect(generatedContentCompositionSchema.safeParse({ contentLocales: ['en', 'de'], contentTypes: [] }).success).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -10,7 +10,7 @@ const CONTRIBUTION_FILE_PATH: Record<string, string> = {
|
|
|
10
10
|
'shell.home': 'src/pages/index.astro',
|
|
11
11
|
'shell.404': 'src/pages/404.astro',
|
|
12
12
|
'shell.localized-paths': 'src/lib/localized-paths.ts',
|
|
13
|
-
'shell.
|
|
13
|
+
'shell.tsconfig': 'tsconfig.json',
|
|
14
14
|
'shell.gitignore': '.gitignore',
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -38,6 +38,8 @@ describe('shell recipe', () => {
|
|
|
38
38
|
const files = buildShellFiles({ noIndex: true });
|
|
39
39
|
const config = files.find((file) => file.path === 'astro.config.mjs')!;
|
|
40
40
|
expect(config.content).toContain('noIndex: true');
|
|
41
|
+
expect(files.find((file) => file.path === 'src/layouts/Base.astro')!.content).toContain('<SeoHead');
|
|
42
|
+
expect(files.some((file) => file.path === 'public/robots.txt')).toBe(false);
|
|
41
43
|
});
|
|
42
44
|
|
|
43
45
|
it('never emits a real domain', () => {
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { posix } from 'node:path';
|
|
3
|
+
import { contentCompositionSchema, defaultReservedContentRoutes } from '../contracts/content-composition.js';
|
|
4
|
+
import type { ContentComposition, ContentTypeDefinition } from '../contracts/content-composition.js';
|
|
5
|
+
import { buildShellFiles, shellRecipe } from './shell-recipe.js';
|
|
6
|
+
import type { ShellConfiguration, ShellRecipeOptions } from './shell-recipe.js';
|
|
7
|
+
import type { RecipeGeneratedFile, RecipeMetadata } from './types.js';
|
|
8
|
+
import type { RecipeOutputContribution } from './schema.js';
|
|
9
|
+
|
|
10
|
+
const supportedTraits = new Set(['title', 'slug', 'summary', 'image', 'body']);
|
|
11
|
+
const supportedBindings = new Set(['list', 'detail', 'navigation', 'cms-admin']);
|
|
12
|
+
|
|
13
|
+
export interface ContentSiteOptions {
|
|
14
|
+
readonly mediaFolder?: string;
|
|
15
|
+
readonly shellConfiguration?: ShellConfiguration;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const generatedContentCompositionSchema = contentCompositionSchema.superRefine((composition, context) => {
|
|
19
|
+
if (composition.contentLocales.length !== 1) {
|
|
20
|
+
context.addIssue({ code: 'custom', path: ['contentLocales'], message: 'Content generation currently requires exactly one locale' });
|
|
21
|
+
}
|
|
22
|
+
if (!composition.contentTypes.length) {
|
|
23
|
+
context.addIssue({ code: 'custom', path: ['contentTypes'], message: 'Content generation requires at least one content type' });
|
|
24
|
+
}
|
|
25
|
+
const routes: string[] = [];
|
|
26
|
+
composition.contentTypes.forEach((type, index) => {
|
|
27
|
+
const path = ['contentTypes', index];
|
|
28
|
+
for (const trait of type.traits) {
|
|
29
|
+
if (!supportedTraits.has(trait)) context.addIssue({ code: 'custom', path: [...path, 'traits'], message: `Content generation does not yet support trait "${trait}"` });
|
|
30
|
+
}
|
|
31
|
+
for (const binding of type.bindings) {
|
|
32
|
+
if (!supportedBindings.has(binding)) context.addIssue({ code: 'custom', path: [...path, 'bindings'], message: `Content generation does not yet support binding "${binding}"` });
|
|
33
|
+
}
|
|
34
|
+
if (!type.bindings.includes('list') || !type.bindings.includes('detail')) {
|
|
35
|
+
context.addIssue({ code: 'custom', path: [...path, 'bindings'], message: 'Content generation requires both list and detail bindings' });
|
|
36
|
+
}
|
|
37
|
+
for (const route of Object.values(type.routes)) {
|
|
38
|
+
const base = route.replace(/\/$/, '');
|
|
39
|
+
if (!/^\/[a-z0-9]+(?:-[a-z0-9]+)*(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/.test(base)
|
|
40
|
+
|| defaultReservedContentRoutes.some((reserved) => reserved !== '/' && `${base}/`.startsWith(reserved))) {
|
|
41
|
+
context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Unsupported generated content route "${route}"; use non-reserved lowercase path segments` });
|
|
42
|
+
}
|
|
43
|
+
if (routes.some((other) => base.startsWith(`${other}/`) || other.startsWith(`${base}/`))) {
|
|
44
|
+
context.addIssue({ code: 'custom', path: [...path, 'routes'], message: `Generated list/detail routes overlap at "${route}"` });
|
|
45
|
+
}
|
|
46
|
+
routes.push(base);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function routeBase(type: ContentTypeDefinition, locale: string): string {
|
|
52
|
+
return type.routes[locale]!.replace(/\/$/, '');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function collectionSchema(type: ContentTypeDefinition): string {
|
|
56
|
+
const shapes = ['...titleTraitSchema.unwrap().shape', '...slugTraitSchema.unwrap().shape'];
|
|
57
|
+
if (type.traits.includes('summary')) shapes.push('...summaryTraitSchema.unwrap().shape');
|
|
58
|
+
if (type.traits.includes('image')) {
|
|
59
|
+
shapes.push('image: imageTraitSchema.unwrap().shape.image.unwrap().extend({ src: image() })');
|
|
60
|
+
}
|
|
61
|
+
// File-based IDs keep duplicate public slugs visible to route validation.
|
|
62
|
+
return `${JSON.stringify(type.id)}: defineCollection({
|
|
63
|
+
loader: glob({ pattern: '**/*.md', base: ${JSON.stringify(`./src/content/${type.id}`)}, generateId: ({ entry }) => entry.replace(/\\.md$/, '') }),
|
|
64
|
+
schema: ${type.traits.includes('image') ? '({ image }) => ' : ''}z.object({ ${shapes.join(', ')} }).strict(),
|
|
65
|
+
})`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function adapterSource(type: ContentTypeDefinition, locale: string, index: number): string {
|
|
69
|
+
const contracts = ['HasTitle', 'HasSlug', ...(type.traits.includes('summary') ? ['HasSummary'] : []), ...(type.traits.includes('image') ? ['HasImage'] : [])];
|
|
70
|
+
return `import type { CollectionEntry } from 'astro:content';
|
|
71
|
+
import { assertImplements, type Item, type Linkable, ${contracts.map((name) => `type ${name}`).join(', ')} } from '@easy-web/core/contracts';
|
|
72
|
+
import { composition } from '../../content/definitions';
|
|
73
|
+
|
|
74
|
+
type Entry = CollectionEntry<${JSON.stringify(type.id)}>;
|
|
75
|
+
assertImplements<Entry['data'], ${contracts.join(' & ')}>();
|
|
76
|
+
|
|
77
|
+
export function toItem(entry: Entry): Item & Linkable {
|
|
78
|
+
const data = entry.data;
|
|
79
|
+
return {
|
|
80
|
+
title: data.title,
|
|
81
|
+
${type.traits.includes('summary') ? 'description: data.summary,' : ''}
|
|
82
|
+
${type.traits.includes('image') ? 'image: data.image,' : ''}
|
|
83
|
+
href: composition.contentTypes[${index}].routes[${JSON.stringify(locale)}].replace(/\\/$/, '') + '/' + data.slug + '/',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function listSource(type: ContentTypeDefinition, locale: string): string {
|
|
90
|
+
const prefix = '../'.repeat(routeBase(type, locale).split('/').length);
|
|
91
|
+
return `---
|
|
92
|
+
import { getCollection } from 'astro:content';
|
|
93
|
+
import Base from '${prefix}layouts/Base.astro';
|
|
94
|
+
import { toItem } from '${prefix}lib/content/${type.id}';
|
|
95
|
+
import Card from '@easy-web/core/components/Card.astro';
|
|
96
|
+
import CardGrid from '@easy-web/core/components/CardGrid.astro';
|
|
97
|
+
|
|
98
|
+
const items = (await getCollection(${JSON.stringify(type.id)}))
|
|
99
|
+
.map(toItem).sort((left, right) => left.href < right.href ? -1 : left.href > right.href ? 1 : 0);
|
|
100
|
+
---
|
|
101
|
+
<Base title={${JSON.stringify(type.labels[locale])}}>
|
|
102
|
+
<h1>{${JSON.stringify(type.labels[locale])}}</h1>
|
|
103
|
+
<CardGrid>
|
|
104
|
+
{items.map((item) => <Card item={item} />)}
|
|
105
|
+
</CardGrid>
|
|
106
|
+
</Base>
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function detailSource(type: ContentTypeDefinition, locale: string): string {
|
|
111
|
+
const prefix = '../'.repeat(routeBase(type, locale).split('/').length);
|
|
112
|
+
return `---
|
|
113
|
+
import { getCollection, render, type CollectionEntry } from 'astro:content';
|
|
114
|
+
import type { Rendered, Item, Linkable } from '@easy-web/core/contracts';
|
|
115
|
+
import Base from '${prefix}layouts/Base.astro';
|
|
116
|
+
import { toItem } from '${prefix}lib/content/${type.id}';
|
|
117
|
+
import Prose from '@easy-web/core/components/Prose.astro';
|
|
118
|
+
${type.traits.includes('image') ? "import Media from '@easy-web/core/components/Media.astro';" : ''}
|
|
119
|
+
|
|
120
|
+
export async function getStaticPaths() {
|
|
121
|
+
const entries = await getCollection(${JSON.stringify(type.id)});
|
|
122
|
+
const seen = new Set<string>();
|
|
123
|
+
return entries.map((entry) => {
|
|
124
|
+
if (seen.has(entry.data.slug)) throw new Error('Duplicate content slug: ' + entry.data.slug);
|
|
125
|
+
seen.add(entry.data.slug);
|
|
126
|
+
return { params: { slug: entry.data.slug }, props: { entry } };
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface Props { entry: CollectionEntry<${JSON.stringify(type.id)}> }
|
|
131
|
+
const { entry } = Astro.props;
|
|
132
|
+
const rendered: Rendered<Item & Linkable> = { ...toItem(entry), ...(await render(entry)) };
|
|
133
|
+
const { Content } = rendered;
|
|
134
|
+
---
|
|
135
|
+
<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)}' : ''}>
|
|
136
|
+
<Prose>
|
|
137
|
+
<h1>{rendered.title}</h1>
|
|
138
|
+
{rendered.description && <p>{rendered.description}</p>}
|
|
139
|
+
${type.traits.includes('image') ? '{rendered.image && <Media image={rendered.image} />}' : ''}
|
|
140
|
+
<Content />
|
|
141
|
+
</Prose>
|
|
142
|
+
</Base>
|
|
143
|
+
`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function contentFiles(composition: ContentComposition, options: ContentSiteOptions): readonly RecipeGeneratedFile[] {
|
|
147
|
+
const locale = composition.contentLocales[0]!;
|
|
148
|
+
const mediaFolder = z.string().regex(/^src\/assets(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/)
|
|
149
|
+
.parse(options.mediaFolder ?? 'src/assets');
|
|
150
|
+
const exampleImage = `${mediaFolder}/content-example.svg`;
|
|
151
|
+
const files: RecipeGeneratedFile[] = [
|
|
152
|
+
{ path: 'src/content/definitions.ts', content: `import { defineCollection, z } from 'astro:content';
|
|
153
|
+
import { glob } from 'astro/loaders';
|
|
154
|
+
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';
|
|
155
|
+
|
|
156
|
+
export const composition = ${JSON.stringify(composition, null, 2)} as const;
|
|
157
|
+
|
|
158
|
+
export const collections = {
|
|
159
|
+
${composition.contentTypes.map(collectionSchema).join(',\n ')},
|
|
160
|
+
};
|
|
161
|
+
` },
|
|
162
|
+
{ path: 'src/content.config.ts', content: "export { collections } from './content/definitions';\n" },
|
|
163
|
+
];
|
|
164
|
+
if (composition.contentTypes.some((type) => type.traits.includes('image'))) {
|
|
165
|
+
files.push({ path: 'package.json', content: `${JSON.stringify({ dependencies: { sharp: '^0.35.0' } }, null, 2)}\n` });
|
|
166
|
+
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' });
|
|
167
|
+
}
|
|
168
|
+
for (const [index, type] of composition.contentTypes.entries()) {
|
|
169
|
+
const data = {
|
|
170
|
+
title: `${type.labels[locale]} - ${locale === 'de' ? 'Beispiel' : 'Example'}`,
|
|
171
|
+
slug: 'example',
|
|
172
|
+
...(type.traits.includes('summary') ? { summary: locale === 'de' ? 'Generierter Beispielinhalt.' : 'Generated example content.' } : {}),
|
|
173
|
+
...(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' } } : {}),
|
|
174
|
+
};
|
|
175
|
+
const base = routeBase(type, locale).slice(1);
|
|
176
|
+
files.push(
|
|
177
|
+
{ 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` },
|
|
178
|
+
{ path: `src/lib/content/${type.id}.ts`, content: adapterSource(type, locale, index) },
|
|
179
|
+
{ path: `src/pages/${base}/index.astro`, content: listSource(type, locale) },
|
|
180
|
+
{ path: `src/pages/${base}/[slug].astro`, content: detailSource(type, locale) },
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return files;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Bind package-owned content generation to a validated composition, independently of a CMS. */
|
|
187
|
+
export function createContentSiteRecipes(rawComposition: unknown, options: ContentSiteOptions = {}): {
|
|
188
|
+
readonly shell: RecipeMetadata<ShellRecipeOptions>;
|
|
189
|
+
readonly content: RecipeMetadata;
|
|
190
|
+
} {
|
|
191
|
+
const composition = generatedContentCompositionSchema.parse(rawComposition);
|
|
192
|
+
const locale = composition.contentLocales[0]!;
|
|
193
|
+
const files = contentFiles(composition, options);
|
|
194
|
+
const contributions: RecipeOutputContribution[] = files
|
|
195
|
+
.filter(({ path }) => !path.startsWith('src/pages/'))
|
|
196
|
+
.map(({ path }, index) => ({ kind: path === 'package.json' ? 'dependency' : 'file', id: `content.file.${index}`, target: path }));
|
|
197
|
+
for (const type of composition.contentTypes) {
|
|
198
|
+
contributions.push(
|
|
199
|
+
{ kind: 'content', id: `content.type.${type.id}`, target: type.primary ? 'primary' : 'additional' },
|
|
200
|
+
{ kind: 'route', id: `content.list.${type.id}`, target: `${routeBase(type, locale)}/` },
|
|
201
|
+
{ kind: 'route', id: `content.detail.${type.id}`, target: `${routeBase(type, locale)}/[slug]` },
|
|
202
|
+
...type.bindings.map((binding) => ({ kind: 'binding' as const, id: `content.binding.${type.id}.${binding}`, target: `content.type.${type.id}` })),
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
const navigation = composition.contentTypes.filter((type) => type.bindings.includes('navigation'))
|
|
206
|
+
.map((type) => ({ label: type.labels[locale]!, href: `${routeBase(type, locale)}/` }));
|
|
207
|
+
return {
|
|
208
|
+
shell: {
|
|
209
|
+
...shellRecipe,
|
|
210
|
+
validators: [{
|
|
211
|
+
id: 'shell.content-locale', phase: 'options',
|
|
212
|
+
validate: ({ options }) => options.defaultLocale === locale ? [] : [{ code: 'CONTENT_LOCALE_MISMATCH', message: 'shell.defaultLocale must match the content composition locale' }],
|
|
213
|
+
}],
|
|
214
|
+
generate: ({ options: shellOptions }) => ({ files: buildShellFiles(shellOptions, navigation, options.shellConfiguration) }),
|
|
215
|
+
},
|
|
216
|
+
content: {
|
|
217
|
+
id: 'content.pages', version: '1.7.1', protocolVersion: 1,
|
|
218
|
+
compatibleCliRange: '^0.1.0 || ^0.2.0', compatibleRuntimeRange: '^1.7.1',
|
|
219
|
+
provides: ['content.pages', 'content.typed-definitions'], requires: ['site.shell'], conflicts: [],
|
|
220
|
+
order: { priority: 10, key: 'content' }, optionsSchema: z.strictObject({}),
|
|
221
|
+
outputContributions: contributions, validators: [],
|
|
222
|
+
generate: () => ({ files }),
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
package/src/recipes/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'astro/zod';
|
|
2
2
|
import type { RecipeMetadata } from './types.js';
|
|
3
|
+
import type { NavItem } from '../contracts/types.js';
|
|
3
4
|
|
|
4
5
|
export const SHELL_RECIPE_ID = 'site.shell';
|
|
5
6
|
|
|
@@ -13,14 +14,24 @@ export type ShellRecipeOptions = z.infer<typeof shellOptionsSchema>;
|
|
|
13
14
|
|
|
14
15
|
const PLACEHOLDER_SITE_URL = 'https://replace-with-your-domain.example';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
/** Source expressions supplied by first-party recipes, never by CLI configuration. */
|
|
18
|
+
export interface ShellConfiguration {
|
|
19
|
+
readonly imports?: readonly string[];
|
|
20
|
+
readonly integrations?: readonly string[];
|
|
21
|
+
readonly markdownProcessor?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function astroConfig(options: ShellRecipeOptions, configuration: ShellConfiguration): string {
|
|
17
25
|
return `import { defineConfig } from 'astro/config';
|
|
18
26
|
import easyWebSeo from '@easy-web/core/seo';
|
|
27
|
+
${(configuration.imports ?? []).join('\n')}
|
|
19
28
|
|
|
20
29
|
export default defineConfig({
|
|
21
30
|
site: ${JSON.stringify(PLACEHOLDER_SITE_URL)},
|
|
31
|
+
${configuration.markdownProcessor ? `markdown: { processor: ${configuration.markdownProcessor} },` : ''}
|
|
22
32
|
integrations: [
|
|
23
33
|
easyWebSeo({ noIndex: ${options.noIndex ? 'true' : 'false'} }),
|
|
34
|
+
${(configuration.integrations ?? []).map((integration) => `${integration},`).join('\n ')}
|
|
24
35
|
],
|
|
25
36
|
});
|
|
26
37
|
`;
|
|
@@ -28,9 +39,9 @@ export default defineConfig({
|
|
|
28
39
|
|
|
29
40
|
const packageJsonFragment = `${JSON.stringify({
|
|
30
41
|
type: 'module',
|
|
31
|
-
scripts: { dev: 'astro dev', build: 'astro build', preview: 'astro preview' },
|
|
42
|
+
scripts: { dev: 'astro dev', typecheck: 'astro check', build: 'astro build', preview: 'astro preview' },
|
|
32
43
|
dependencies: { '@easy-web/core': '^1.5.0', astro: '^7.3.5' },
|
|
33
|
-
devDependencies: { typescript: '^5.5.0' },
|
|
44
|
+
devDependencies: { '@astrojs/check': '^0.9.4', typescript: '^5.5.0' },
|
|
34
45
|
}, null, 2)}\n`;
|
|
35
46
|
|
|
36
47
|
const pnpmWorkspace = `allowBuilds:
|
|
@@ -38,26 +49,31 @@ const pnpmWorkspace = `allowBuilds:
|
|
|
38
49
|
sharp: true
|
|
39
50
|
`;
|
|
40
51
|
|
|
41
|
-
function baseLayout(options: ShellRecipeOptions): string {
|
|
52
|
+
function baseLayout(options: ShellRecipeOptions, navigation: readonly NavItem[]): string {
|
|
42
53
|
return `---
|
|
43
54
|
import PageShell from '@easy-web/core/components/PageShell.astro';
|
|
44
55
|
import Header from '@easy-web/core/components/Header.astro';
|
|
45
56
|
import Footer from '@easy-web/core/components/Footer.astro';
|
|
57
|
+
import SeoHead from '@easy-web/core/components/SeoHead.astro';
|
|
58
|
+
import '@easy-web/core/styles/tokens.css';
|
|
46
59
|
|
|
47
60
|
interface Props {
|
|
48
61
|
title: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
image?: string;
|
|
49
64
|
}
|
|
50
|
-
const { title } = Astro.props;
|
|
65
|
+
const { title, description, image } = Astro.props;
|
|
51
66
|
const siteName = ${JSON.stringify(options.siteName)};
|
|
52
67
|
const currentLang = ${JSON.stringify(options.defaultLocale)};
|
|
53
|
-
const navItems = [{ label: 'Home', href: '/' }];
|
|
68
|
+
const navItems = ${JSON.stringify([{ label: options.defaultLocale === 'de' ? 'Startseite' : 'Home', href: '/' }, ...navigation])};
|
|
54
69
|
---
|
|
55
70
|
<!doctype html>
|
|
56
71
|
<html lang=${JSON.stringify(options.defaultLocale)}>
|
|
57
72
|
<head>
|
|
58
73
|
<meta charset="utf-8" />
|
|
59
74
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
60
|
-
<title
|
|
75
|
+
<SeoHead title={title} description={description} ogImage={image}
|
|
76
|
+
pathname={Astro.url.pathname} locale={currentLang} siteName={siteName} />
|
|
61
77
|
</head>
|
|
62
78
|
<body>
|
|
63
79
|
<PageShell lang={currentLang}>
|
|
@@ -109,26 +125,22 @@ const localizedPaths = `import type { LocalizedPathGroup } from '@easy-web/core/
|
|
|
109
125
|
export const localizedPaths: readonly LocalizedPathGroup[] = [];
|
|
110
126
|
`;
|
|
111
127
|
|
|
112
|
-
const robotsTxt = `Disallow: /admin/
|
|
113
|
-
Sitemap: ${PLACEHOLDER_SITE_URL}/sitemap-index.xml
|
|
114
|
-
`;
|
|
115
|
-
|
|
116
128
|
const gitignore = `node_modules
|
|
117
129
|
dist
|
|
118
130
|
.astro
|
|
119
131
|
`;
|
|
120
132
|
|
|
121
|
-
export function buildShellFiles(rawOptions: unknown): readonly { path: string; content: string }[] {
|
|
133
|
+
export function buildShellFiles(rawOptions: unknown, navigation: readonly NavItem[] = [], configuration: ShellConfiguration = {}): readonly { path: string; content: string }[] {
|
|
122
134
|
const options = shellOptionsSchema.parse(rawOptions ?? {});
|
|
123
135
|
return [
|
|
124
|
-
{ path: 'astro.config.mjs', content: astroConfig(options) },
|
|
136
|
+
{ path: 'astro.config.mjs', content: astroConfig(options, configuration) },
|
|
125
137
|
{ path: 'package.json', content: packageJsonFragment },
|
|
126
138
|
{ path: 'pnpm-workspace.yaml', content: pnpmWorkspace },
|
|
127
|
-
{ path: 'src/layouts/Base.astro', content: baseLayout(options) },
|
|
139
|
+
{ path: 'src/layouts/Base.astro', content: baseLayout(options, navigation) },
|
|
128
140
|
{ path: 'src/pages/index.astro', content: homePage(options) },
|
|
129
141
|
{ path: 'src/pages/404.astro', content: notFoundPage(options) },
|
|
130
142
|
{ path: 'src/lib/localized-paths.ts', content: localizedPaths },
|
|
131
|
-
{ path: '
|
|
143
|
+
{ path: 'tsconfig.json', content: `${JSON.stringify({ extends: 'astro/tsconfigs/strict', include: ['.astro/types.d.ts', '**/*'], exclude: ['dist'] }, null, 2)}\n` },
|
|
132
144
|
{ path: '.gitignore', content: gitignore },
|
|
133
145
|
];
|
|
134
146
|
}
|
|
@@ -137,7 +149,7 @@ export const shellRecipe = {
|
|
|
137
149
|
id: SHELL_RECIPE_ID,
|
|
138
150
|
version: '1.5.0',
|
|
139
151
|
protocolVersion: 1,
|
|
140
|
-
compatibleCliRange: '^0.1.0',
|
|
152
|
+
compatibleCliRange: '^0.1.0 || ^0.2.0',
|
|
141
153
|
compatibleRuntimeRange: '^1.5.0',
|
|
142
154
|
provides: [SHELL_RECIPE_ID],
|
|
143
155
|
requires: [],
|
|
@@ -152,7 +164,7 @@ export const shellRecipe = {
|
|
|
152
164
|
{ kind: 'route', id: 'shell.home', target: '/' },
|
|
153
165
|
{ kind: 'route', id: 'shell.404', target: '/404' },
|
|
154
166
|
{ kind: 'file', id: 'shell.localized-paths', target: 'src/lib/localized-paths.ts' },
|
|
155
|
-
{ kind: '
|
|
167
|
+
{ kind: 'configuration', id: 'shell.tsconfig', target: 'tsconfig.json' },
|
|
156
168
|
{ kind: 'file', id: 'shell.gitignore', target: '.gitignore' },
|
|
157
169
|
],
|
|
158
170
|
validators: [],
|