@contentrain/emitter-astro 0.2.1 → 0.4.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 +4 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +134 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,6 +20,10 @@ await writeEmit(result, './out/site')
|
|
|
20
20
|
|---|---|
|
|
21
21
|
| Layouts (`src/layouts/*.astro`) | One per `LayoutFamily`. Chrome travels as **data** (`src/data/chrome/*.json`) injected via `set:html` — the Astro compiler never parses theme markup. `@@mark@@` placeholders (title, author, `date{n}`, `term{n}`, `feat{n}`, slug) are filled per page. |
|
|
22
22
|
| Pages (`src/pages/…`) | From `RouteModel` patterns: `single` routes render post bodies; list routes render items through the extracted `item_template` (plain fallback list + warning when absent). Pagination is a route param, never a separate family. |
|
|
23
|
+
| Template markers | `@@mark@@` (escaped) · `@@mark_html@@` (raw, for themes printing a post's own markup) · `<!--@@repeat:list|sep@@-->…<!--@@/repeat@@-->` (per item, with `item` / `item_index` / `item_<key>`) · `<!--@@if:name@@-->…<!--@@/if@@-->` (and `if:!name`). Rendered repeats → conditionals → marks. |
|
|
24
|
+
| Route parameters | Each post carries its own (`EmitPost.params`) — a dated permalink (`/:year/:month/:day/:slug`) generates every post at its real address, so redirects stay unnecessary. |
|
|
25
|
+
| Per-page CSS | `EmitPost.css` / `QueryPage.css` load stylesheets only that page needs (page-builder sites emit CSS per page); the family's `css.files` is the shared union. |
|
|
26
|
+
| Root attributes | `LayoutFamily.root_attrs` lands on `<html>`/`<body>` verbatim — themes key their container rules off `wp-singular`, `single`, `js`, `wf-…`; dropping them costs a correct-content page its whole layout. Values may carry `@@marks@@` (per-page classes like `postid-123`). |
|
|
23
27
|
| Legacy CSS (`public/styles/legacy/`) | Quarantined in `@layer legacy { … }` with leading `@import`s hoisted and layered; a mid-file `@import` is left as-is with a warning. |
|
|
24
28
|
| Evolution layer (`src/styles/modern.css`) | Tailwind 4, CSS-first: extracted design tokens land in `@theme`. Migrated layouts never load it; new pages build on it. |
|
|
25
29
|
| Components (`src/components/*.astro`) | `<cr-component>` placeholders carrying type/source/variants; `runtime`-sourced ones point to the migration handoff offers. |
|
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,18 @@ interface EmitPost {
|
|
|
13
13
|
title: string;
|
|
14
14
|
/** Rendered, asset-rewritten HTML body. */
|
|
15
15
|
body: string;
|
|
16
|
+
/**
|
|
17
|
+
* Route parameters for this post beyond `slug` — the date parts of a
|
|
18
|
+
* `/%year%/%monthnum%/%day%/%postname%/` permalink, a post id, anything the
|
|
19
|
+
* route pattern names. Without them every post but the template one would be
|
|
20
|
+
* generated at the wrong address.
|
|
21
|
+
*/
|
|
22
|
+
params?: Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Stylesheets only this page loads (page-builder sites emit CSS per page).
|
|
25
|
+
* Family-level stylesheets stay on `LayoutFamily.css.files`.
|
|
26
|
+
*/
|
|
27
|
+
css?: string[];
|
|
16
28
|
/** The site's date-format catalog applied to this post's date (index-aligned with `date{n}` marks). */
|
|
17
29
|
dates?: string[];
|
|
18
30
|
author?: string;
|
|
@@ -22,11 +34,25 @@ interface EmitPost {
|
|
|
22
34
|
/** Local featured-image file names (largest first). */
|
|
23
35
|
featured?: string[];
|
|
24
36
|
excerpt?: string;
|
|
37
|
+
/** Excerpt as source HTML, for themes whose cards keep links and formatting. */
|
|
38
|
+
excerpt_html?: string;
|
|
39
|
+
/** Every author, for repeat blocks — `author` stays the first one. */
|
|
40
|
+
authors?: string[];
|
|
41
|
+
/** Producer-supplied extra marks, merged last. */
|
|
42
|
+
marks?: Record<string, unknown>;
|
|
25
43
|
}
|
|
26
44
|
/** One static path of a list route: its params and the items its list renders. */
|
|
27
45
|
interface QueryPage {
|
|
28
46
|
params: Record<string, string>;
|
|
29
47
|
items: EmitPost[];
|
|
48
|
+
/**
|
|
49
|
+
* Page-level marks for the list page's chrome — a term's display NAME where
|
|
50
|
+
* the route parameter only carries its slug, its description, its count.
|
|
51
|
+
* Without these every category page would print the template category's name.
|
|
52
|
+
*/
|
|
53
|
+
marks?: Record<string, unknown>;
|
|
54
|
+
/** Stylesheets only this list page loads. */
|
|
55
|
+
css?: string[];
|
|
30
56
|
/**
|
|
31
57
|
* Item markup with `@@mark@@` placeholders (title, date{n}, author, excerpt,
|
|
32
58
|
* feat, slug), extracted from the source list. When present, list pages
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/css.ts","../src/util.ts","../src/index.ts"],"mappings":";;;;;AAWA;;;;;UAAiB,QAAA;EACf,IAAA;EACA,KAAA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/css.ts","../src/util.ts","../src/index.ts"],"mappings":";;;;;AAWA;;;;;UAAiB,QAAA;EACf,IAAA;EACA,KAAA;EASS;EAPT,IAAA;EAcA;;;;;;EAPA,MAAA,GAAS,MAAA;EAgBT;;;;EAXA,GAAA;EAec;EAbd,KAAA;EACA,MAAA;EACA,YAAA;EACA,WAAA;EACA,KAAA;EAqBQ;EAnBR,QAAA;EACA,OAAA;EAWA;EATA,YAAA;EAUA;EARA,OAAA;EAcA;EAZA,KAAA,GAAQ,MAAA;AAAA;;UAIO,SAAA;EACf,MAAA,EAAQ,MAAA;EACR,KAAA,EAAO,QAAA;EAmBmB;;;;;EAb1B,KAAA,GAAQ,MAAA;EAiBQ;EAfhB,GAAA;EAaQ;;;;;;AAMV;EAXE,aAAA;AAAA;AAAA,UAGe,WAAA;EAUR;EARP,KAAA,GAAQ,QAAA;EAWkB;EAT1B,OAAA,GAAU,MAAA,SAAe,SAAA;AAAA;;UAIV,WAAA;EACf,IAAA;EACA,OAAA;AAAA;AAAA,UAGe,WAAA;EAUT;EARN,WAAA;EASqB;EAPrB,QAAA;AAAA;AAAA,UAGe,SAAA;EACf,EAAA,EAAI,SAAA;EACJ,OAAA,GAAU,WAAA;EACV,GAAA,GAAM,WAAA;EACN,OAAA,GAAU,WAAA;AAAA;;;;AAUZ;;UAAiB,UAAA;EACf,KAAA,EAAO,MAAA;EACP,QAAA;AAAA;;;UCvFe,aAAA;EACf,OAAA;EACA,OAAA;AAAA;AAAA,iBAKc,aAAA,CAAc,IAAA,UAAc,GAAA,WAAc,aAAA;;;;iBCtB1C,UAAA,CAAW,EAAA;;AFU3B;;;;iBEGgB,iBAAA,CAAkB,OAAA;;iBAuBlB,UAAA,CAAW,KAAA;;;iBCrBX,gBAAA,CAAiB,KAAA,EAAO,SAAA,GAAY,UAAA;;iBAwD9B,SAAA,CAAU,MAAA,EAAQ,UAAA,EAAY,GAAA,WAAc,OAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -38,7 +38,7 @@ function scaffoldFiles(ir, options) {
|
|
|
38
38
|
type: "module",
|
|
39
39
|
scripts: {
|
|
40
40
|
dev: "astro dev",
|
|
41
|
-
build: "astro build",
|
|
41
|
+
build: "astro check && astro build",
|
|
42
42
|
preview: "astro preview",
|
|
43
43
|
...split ? {
|
|
44
44
|
"build:desktop": "VIEWPORT=desktop astro build --outDir dist/desktop",
|
|
@@ -51,6 +51,10 @@ function scaffoldFiles(ir, options) {
|
|
|
51
51
|
tailwindcss: "^4.0.0",
|
|
52
52
|
"@tailwindcss/vite": "^4.0.0"
|
|
53
53
|
} : {}
|
|
54
|
+
},
|
|
55
|
+
devDependencies: {
|
|
56
|
+
"@astrojs/check": "^0.9.0",
|
|
57
|
+
typescript: "^5.7.0"
|
|
54
58
|
}
|
|
55
59
|
});
|
|
56
60
|
files["astro.config.mjs"] = [
|
|
@@ -88,59 +92,136 @@ function modernCss(tokens) {
|
|
|
88
92
|
if (theme.length) lines.push(`@theme {`, ...theme, `}`);
|
|
89
93
|
return `${lines.join("\n")}\n`;
|
|
90
94
|
}
|
|
91
|
-
const FILL_TS = `// Emitted by @contentrain/emitter-astro —
|
|
92
|
-
//
|
|
95
|
+
const FILL_TS = `// Emitted by @contentrain/emitter-astro — the template runtime.
|
|
96
|
+
//
|
|
97
|
+
// Chrome, item templates and attribute values carry three marker forms:
|
|
98
|
+
// @@mark@@ — a value, escaped
|
|
99
|
+
// @@mark_html@@ — a value, raw HTML
|
|
100
|
+
// <!--@@repeat:list@@-->…<!--@@/repeat@@--> — once per list item
|
|
101
|
+
// <!--@@if:name@@-->…<!--@@/if@@--> — only when name has a value
|
|
102
|
+
// Rendering order is repeats → conditionals → marks, so a repeat body may hold
|
|
103
|
+
// conditionals and marks that only make sense per item.
|
|
93
104
|
|
|
94
105
|
/** Where page content splices into the body chrome — must match @contentrain/types CHROME_BODY_SLOT. */
|
|
95
106
|
export const BODY_SLOT = '<!--@@body@@-->'
|
|
96
107
|
|
|
108
|
+
const REPEAT_RE = /<!--@@repeat:([a-z0-9_]+)(?:\\|([\\s\\S]*?))?@@-->([\\s\\S]*?)<!--@@\\/repeat@@-->/gi
|
|
109
|
+
const IF_RE = /<!--@@if:(!?)([a-z0-9_]+)@@-->([\\s\\S]*?)<!--@@\\/if@@-->/gi
|
|
110
|
+
const MARK_RE = /@@([a-z0-9_]+)@@/gi
|
|
111
|
+
|
|
112
|
+
export type Values = Record<string, unknown>
|
|
113
|
+
|
|
97
114
|
export const esc = (value: unknown): string =>
|
|
98
115
|
String(value ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
99
116
|
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
const isFilled = (value: unknown): boolean =>
|
|
118
|
+
Array.isArray(value) ? value.length > 0 : value !== undefined && value !== null && value !== ''
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Replace @@marks@@. Values are escaped unless the mark name ends in _html —
|
|
122
|
+
* escaping is the default so content-derived text can never break the page,
|
|
123
|
+
* and the _html opt-in exists for themes that print a post's own markup
|
|
124
|
+
* (full content in a list card, a link-bearing excerpt).
|
|
125
|
+
*/
|
|
126
|
+
export function fillMarks(html: string, values: Values): string {
|
|
127
|
+
return html.replace(MARK_RE, (_all, key: string) => {
|
|
128
|
+
const value = values[key]
|
|
129
|
+
if (Array.isArray(value)) return value.map((v) => esc(v)).join(', ')
|
|
130
|
+
return key.toLowerCase().endsWith('_html') ? String(value ?? '') : esc(value ?? '')
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Expand repeat blocks; each item renders the inner fragment with its own values. */
|
|
135
|
+
export function expandRepeats(html: string, values: Values): string {
|
|
136
|
+
return html.replace(REPEAT_RE, (_all, name: string, sep: string | undefined, inner: string) => {
|
|
137
|
+
const list = values[name]
|
|
138
|
+
if (!Array.isArray(list) || list.length === 0) return ''
|
|
139
|
+
return list
|
|
140
|
+
.map((item, index) => {
|
|
141
|
+
const itemValues: Values = { ...values, item, item_index: String(index) }
|
|
142
|
+
if (item && typeof item === 'object') {
|
|
143
|
+
for (const [k, v] of Object.entries(item as Record<string, unknown>)) itemValues['item_' + k] = v
|
|
144
|
+
}
|
|
145
|
+
return renderTemplate(inner, itemValues)
|
|
146
|
+
})
|
|
147
|
+
.join(sep ?? '')
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Drop conditional blocks whose value is empty (or present, when negated). */
|
|
152
|
+
export function applyConditions(html: string, values: Values): string {
|
|
153
|
+
return html.replace(IF_RE, (_all, negate: string, name: string, inner: string) =>
|
|
154
|
+
isFilled(values[name]) !== (negate === '!') ? inner : '',
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Full render: repeats → conditionals → marks. */
|
|
159
|
+
export function renderTemplate(html: string, values: Values): string {
|
|
160
|
+
return fillMarks(applyConditions(expandRepeats(html, values), values), values)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Fill marks inside attribute values (per-page classes like postid-123). */
|
|
164
|
+
export function fillAttrs(attrs: Record<string, string> | undefined, values: Values): Record<string, string> {
|
|
165
|
+
const out: Record<string, string> = {}
|
|
166
|
+
for (const [name, value] of Object.entries(attrs ?? {})) out[name] = fillMarks(value, values)
|
|
167
|
+
return out
|
|
102
168
|
}
|
|
103
169
|
|
|
104
170
|
/**
|
|
105
171
|
* Compose the body chrome with the page content. The split happens BEFORE any
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
172
|
+
* rendering: the @@…@@ pattern would otherwise consume the @@body@@ inside the
|
|
173
|
+
* marker comment, leaving <!----> behind and silently dropping the content
|
|
174
|
+
* (measured cost on a real page: 49.8 vs 97.8).
|
|
109
175
|
*/
|
|
110
|
-
export function composeBody(chromeBody: string,
|
|
176
|
+
export function composeBody(chromeBody: string, values: Values, content: string): string {
|
|
111
177
|
return chromeBody
|
|
112
178
|
.split(BODY_SLOT)
|
|
113
|
-
.map((part) =>
|
|
179
|
+
.map((part) => renderTemplate(part, values))
|
|
114
180
|
.join(content)
|
|
115
181
|
}
|
|
116
182
|
|
|
183
|
+
/** Emitted stylesheets live under /styles/legacy/ — pages reference them by file name. */
|
|
184
|
+
export const cssHref = (file: string): string => '/styles/legacy/' + (file.split('/').pop() ?? file)
|
|
185
|
+
|
|
117
186
|
export interface MarkablePost {
|
|
118
187
|
slug: string
|
|
119
188
|
title: string
|
|
189
|
+
body?: string
|
|
120
190
|
dates?: string[]
|
|
121
191
|
author?: string
|
|
122
192
|
author_first?: string
|
|
123
193
|
author_last?: string
|
|
194
|
+
authors?: string[]
|
|
124
195
|
terms?: string[]
|
|
125
196
|
featured?: string[]
|
|
126
197
|
excerpt?: string
|
|
198
|
+
excerpt_html?: string
|
|
199
|
+
marks?: Record<string, unknown>
|
|
127
200
|
}
|
|
128
201
|
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
202
|
+
/**
|
|
203
|
+
* The mark vocabulary: title, author (+ first/last), date{n}, term{n}, feat{n},
|
|
204
|
+
* excerpt, slug — plus \`terms\`/\`authors\` as LISTS for repeat blocks, the
|
|
205
|
+
* _html variants for raw insertion, and any producer-supplied extras.
|
|
206
|
+
*/
|
|
207
|
+
export function postMarks(post: MarkablePost): Values {
|
|
208
|
+
const values: Values = {
|
|
132
209
|
title: post.title,
|
|
133
210
|
author: post.author ?? '',
|
|
134
211
|
author_first: post.author_first ?? '',
|
|
135
212
|
author_last: post.author_last ?? '',
|
|
136
213
|
excerpt: post.excerpt ?? '',
|
|
214
|
+
excerpt_html: post.excerpt_html ?? post.excerpt ?? '',
|
|
215
|
+
body_html: post.body ?? '',
|
|
137
216
|
slug: post.slug,
|
|
138
217
|
feat: post.featured?.[0] ?? '',
|
|
218
|
+
terms: post.terms ?? [],
|
|
219
|
+
authors: post.authors ?? (post.author ? [post.author] : []),
|
|
139
220
|
}
|
|
140
|
-
for (const [i, d] of (post.dates ?? []).entries())
|
|
141
|
-
for (const [i, t] of (post.terms ?? []).entries())
|
|
142
|
-
for (const [i, f] of (post.featured ?? []).entries())
|
|
143
|
-
return marks
|
|
221
|
+
for (const [i, d] of (post.dates ?? []).entries()) values['date' + i] = d
|
|
222
|
+
for (const [i, t] of (post.terms ?? []).entries()) values['term' + i] = t
|
|
223
|
+
for (const [i, f] of (post.featured ?? []).entries()) values['feat' + i] = f
|
|
224
|
+
return { ...values, ...(post.marks ?? {}) }
|
|
144
225
|
}
|
|
145
226
|
`;
|
|
146
227
|
//#endregion
|
|
@@ -162,37 +243,48 @@ function familyFiles(family, lang) {
|
|
|
162
243
|
const files = {};
|
|
163
244
|
files[`src/data/chrome/${family.id}.json`] = stableJson({
|
|
164
245
|
head: joined("head"),
|
|
165
|
-
body
|
|
246
|
+
body,
|
|
247
|
+
html_attrs: family.root_attrs?.html ?? {},
|
|
248
|
+
body_attrs: family.root_attrs?.body ?? {}
|
|
166
249
|
});
|
|
167
250
|
const cssLinks = (family.css.files ?? []).map((f) => `<link rel="stylesheet" href="/styles/legacy/${f.split("/").pop()}" />`).join("\n");
|
|
168
251
|
files[`src/layouts/${name}.astro`] = `---
|
|
169
252
|
// Family: ${family.id}${family.name ? ` (${family.name})` : ""} — emitted by @contentrain/emitter-astro
|
|
170
253
|
import chrome from '../data/chrome/${family.id}.json'
|
|
171
|
-
import {
|
|
254
|
+
import { cssHref, fillAttrs, renderTemplate, composeBody } from '../lib/fill'
|
|
172
255
|
|
|
173
256
|
interface Props {
|
|
174
257
|
title?: string
|
|
175
|
-
marks?: Record<string,
|
|
258
|
+
marks?: Record<string, unknown>
|
|
176
259
|
/** Page content as an HTML string; slot children are used when absent. */
|
|
177
260
|
body?: string
|
|
261
|
+
/** Stylesheets only this page loads (page-builder sites emit CSS per page). */
|
|
262
|
+
css?: string[]
|
|
178
263
|
}
|
|
179
|
-
const { title = '', marks = {}, body } = Astro.props
|
|
180
|
-
const head =
|
|
264
|
+
const { title = '', marks = {}, body, css = [] } = Astro.props
|
|
265
|
+
const head = renderTemplate(chrome.head, marks)
|
|
266
|
+
// Root attributes carry the theme's layout hooks; values may hold @@marks@@.
|
|
267
|
+
// An explicit lang from the source wins over the project default.
|
|
268
|
+
const htmlAttrs = { lang: ${JSON.stringify(lang)}, ...fillAttrs(chrome.html_attrs, marks) }
|
|
269
|
+
const bodyAttrs = fillAttrs(chrome.body_attrs, marks)
|
|
181
270
|
const content = body ?? (Astro.slots.has('default') ? await Astro.slots.render('default') : '')
|
|
182
271
|
// Split at the marker FIRST, then fill marks per side — filling first would
|
|
183
272
|
// eat the @@body@@ inside the marker and silently drop the content.
|
|
184
273
|
const html = composeBody(chrome.body, marks, content)
|
|
185
274
|
---
|
|
186
275
|
<!doctype html>
|
|
187
|
-
<html
|
|
276
|
+
<html {...htmlAttrs}>
|
|
188
277
|
<head>
|
|
189
278
|
<meta charset="utf-8" />
|
|
190
279
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
191
280
|
${cssLinks.split("\n").filter(Boolean).map((l) => ` ${l}`).join("\n")}
|
|
281
|
+
{css.map((file) => (
|
|
282
|
+
<link rel="stylesheet" href={cssHref(file)} />
|
|
283
|
+
))}
|
|
192
284
|
<Fragment set:html={head} />
|
|
193
285
|
<title>{title}</title>
|
|
194
286
|
</head>
|
|
195
|
-
<body>
|
|
287
|
+
<body {...bodyAttrs}>
|
|
196
288
|
<Fragment set:html={html} />
|
|
197
289
|
</body>
|
|
198
290
|
</html>
|
|
@@ -255,12 +347,15 @@ import posts from '${up}data/posts.json'
|
|
|
255
347
|
import { postMarks } from '${up}lib/fill'
|
|
256
348
|
|
|
257
349
|
export function getStaticPaths() {
|
|
258
|
-
|
|
350
|
+
// A post carries its own route parameters (date parts of a dated permalink,
|
|
351
|
+
// a post id) — using the template post's would send every other post to the
|
|
352
|
+
// wrong address.
|
|
353
|
+
return posts.map((post) => ({ params: { ...(post.params ?? {}), slug: post.slug }, props: { post } }))
|
|
259
354
|
}
|
|
260
355
|
type Props = { post: (typeof posts)[number] }
|
|
261
356
|
const { post } = Astro.props as Props
|
|
262
357
|
---
|
|
263
|
-
<Layout title={post.title} marks={postMarks(post)} body={post.body} />
|
|
358
|
+
<Layout title={post.title} marks={postMarks(post)} body={post.body} css={post.css ?? []} />
|
|
264
359
|
`;
|
|
265
360
|
}
|
|
266
361
|
function listPage(route, layout, up, hasParams) {
|
|
@@ -273,11 +368,11 @@ const { page } = Astro.props as Props` : `const page = pages[0] ?? { params: {},
|
|
|
273
368
|
// Route: ${route.id} (${route.pattern}) — emitted by @contentrain/emitter-astro
|
|
274
369
|
import Layout from '${up}layouts/${layout}.astro'
|
|
275
370
|
import pages from '${up}data/queries/${route.query}.json'
|
|
276
|
-
import { esc,
|
|
371
|
+
import { esc, postMarks, renderTemplate } from '${up}lib/fill'
|
|
277
372
|
|
|
278
373
|
${paths}
|
|
279
374
|
const items = page.items.map((item) =>
|
|
280
|
-
page.item_template ?
|
|
375
|
+
page.item_template ? renderTemplate(page.item_template, postMarks(item)) : undefined,
|
|
281
376
|
)
|
|
282
377
|
const fallback = items.some((h) => h === undefined)
|
|
283
378
|
const content = fallback
|
|
@@ -285,8 +380,11 @@ const content = fallback
|
|
|
285
380
|
page.items.map((item) => '<li><a href="/' + item.slug + '/">' + esc(item.title) + '</a></li>').join('') +
|
|
286
381
|
'</ul>'
|
|
287
382
|
: items.join('')
|
|
383
|
+
// Route params carry slugs; page marks carry what the chrome needs to SHOW
|
|
384
|
+
// (a term's display name, description, count).
|
|
385
|
+
const marks = { ...page.params, ...(page.marks ?? {}) }
|
|
288
386
|
---
|
|
289
|
-
<Layout title={page.params.term ?? ''} marks={
|
|
387
|
+
<Layout title={String(marks.term_name ?? page.params.term ?? '')} marks={marks} body={content} css={page.css ?? []} />
|
|
290
388
|
`;
|
|
291
389
|
}
|
|
292
390
|
function staticPage(route, layout, up, hasParams, warnings) {
|
|
@@ -362,10 +460,13 @@ function emitAstroProject(input) {
|
|
|
362
460
|
if (wrapped.warning) warnings.push(wrapped.warning);
|
|
363
461
|
add({ [`public/styles/legacy/${css.path.split("/").pop() ?? css.path}`]: wrapped.content });
|
|
364
462
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
463
|
+
const providedCss = new Set((input.css ?? []).map((c) => c.path.split("/").pop() ?? c.path));
|
|
464
|
+
const missingCss = (refs, owner) => {
|
|
465
|
+
for (const ref of refs ?? []) if (!providedCss.has(ref.split("/").pop() ?? ref)) warnings.push(`${owner}: css file "${ref}" not provided in input.css`);
|
|
466
|
+
};
|
|
467
|
+
for (const family of ir.families) missingCss(family.css.files, `family ${family.id}`);
|
|
468
|
+
for (const post of input.content?.posts ?? []) missingCss(post.css, `post ${post.slug}`);
|
|
469
|
+
for (const [queryId, queryPages] of Object.entries(input.content?.queries ?? {})) for (const qp of queryPages) missingCss(qp.css, `query ${queryId}`);
|
|
369
470
|
for (const route of ir.routes) {
|
|
370
471
|
const result = routeFiles(route, familiesById.get(route.family), input.content ?? {});
|
|
371
472
|
add(result.files);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/util.ts","../src/scaffold.ts","../src/layouts.ts","../src/pages.ts","../src/components.ts","../src/css.ts","../src/index.ts"],"sourcesContent":["/** \"f-archive\" → \"FArchive\", \"posts\" → \"Posts\" — Astro component file names. */\nexport function pascalCase(id: string): string {\n return id\n .split(/[^a-zA-Z0-9]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')\n}\n\n/**\n * Route pattern → Astro pages path.\n * `/` → `index.astro`; `/category/:term/page/:page` → `category/[term]/page/[page].astro`.\n * Returns null for patterns Astro's file routing cannot express (recorded as a warning upstream).\n */\nexport function patternToPagePath(pattern: string): string | null {\n if (pattern === '/' || pattern === '') return 'index.astro'\n if (pattern.includes('*')) return null\n const segments = pattern.replace(/^\\/+|\\/+$/g, '').split('/')\n const mapped = segments.map((seg) => (seg.startsWith(':') ? `[${seg.slice(1)}]` : seg))\n if (mapped.some((seg) => !/^[[\\]a-zA-Z0-9._-]+$/.test(seg))) return null\n const last = mapped.pop()\n return [...mapped, `${last}.astro`].join('/')\n}\n\nconst sortDeep = (v: unknown): unknown => {\n if (Array.isArray(v)) return v.map(sortDeep)\n if (v && typeof v === 'object') {\n return Object.fromEntries(\n Object.entries(v as Record<string, unknown>)\n .toSorted(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, val]) => [k, sortDeep(val)]),\n )\n }\n return v\n}\n\n/** JSON with stable key order and trailing newline — deterministic output, stable diffs. */\nexport function stableJson(value: unknown): string {\n return `${JSON.stringify(sortDeep(value), null, 2)}\\n`\n}\n","// Project scaffolding: manifest, config, styles, and the shared fill helper\n// the generated pages use to pour content into `@@mark@@` placeholders.\n\nimport type { DesignTokens, ProjectIR } from '@contentrain/types'\nimport type { EmitOptions } from './types.js'\nimport { stableJson } from './util.js'\n\nexport function scaffoldFiles(ir: ProjectIR, options: EmitOptions): Record<string, string> {\n const tailwind = options.tailwind !== false\n const split = ir.viewport_strategy === 'split'\n const files: Record<string, string> = {}\n\n const pkg: Record<string, unknown> = {\n name: options.projectName ?? 'migrated-site',\n private: true,\n type: 'module',\n scripts: {\n dev: 'astro dev',\n build: 'astro build',\n preview: 'astro preview',\n // Split viewport production (skeleton): one build per device class, served by device.\n ...(split ? { 'build:desktop': 'VIEWPORT=desktop astro build --outDir dist/desktop', 'build:mobile': 'VIEWPORT=mobile astro build --outDir dist/mobile' } : {}),\n },\n dependencies: {\n astro: '^5.0.0',\n ...(tailwind ? { tailwindcss: '^4.0.0', '@tailwindcss/vite': '^4.0.0' } : {}),\n },\n }\n files['package.json'] = stableJson(pkg)\n\n files['astro.config.mjs'] = [\n `import { defineConfig } from 'astro/config'`,\n ...(tailwind ? [`import tailwindcss from '@tailwindcss/vite'`] : []),\n ``,\n `export default defineConfig({`,\n // Canonical URLs and sitemaps hang off \\`site\\` — for a migration, SEO\n // continuity is the point, so the source site's URL always lands here.\n ` site: ${JSON.stringify(ir.site.url)},`,\n ` build: { format: 'directory' },`,\n ...(tailwind ? [` vite: { plugins: [tailwindcss()] },`] : []),\n `})`,\n ``,\n ].join('\\n')\n\n // Astro wants a tsconfig in every project — editors and the compiler read\n // it even in JS-only projects, and the emitted src/lib/fill.ts is TS.\n files['tsconfig.json'] = `${JSON.stringify({ extends: 'astro/tsconfigs/base', include: ['.astro/types.d.ts', '**/*'], exclude: ['dist'] }, null, 2)}\\n`\n\n if (tailwind) files['src/styles/modern.css'] = modernCss(ir.tokens)\n\n files['src/lib/fill.ts'] = FILL_TS\n return files\n}\n\n/** Tailwind 4 evolution layer: CSS-first config with the site's extracted tokens. */\nfunction modernCss(tokens: DesignTokens | undefined): string {\n const lines: string[] = [`@import 'tailwindcss';`, ``]\n const theme: string[] = []\n const push = (prefix: string, map: Record<string, string> | undefined) => {\n for (const [key, value] of Object.entries(map ?? {})) theme.push(` --${prefix}-${key}: ${value};`)\n }\n push('color', tokens?.colors)\n push('font', tokens?.font_families)\n push('text', tokens?.font_sizes)\n push('spacing', tokens?.spacing)\n push('breakpoint', tokens?.breakpoints)\n if (theme.length) lines.push(`@theme {`, ...theme, `}`)\n return `${lines.join('\\n')}\\n`\n}\n\nconst FILL_TS = `// Emitted by @contentrain/emitter-astro — shared mark-filling helpers.\n// Chrome and item templates carry @@mark@@ placeholders; pages fill them from content.\n\n/** Where page content splices into the body chrome — must match @contentrain/types CHROME_BODY_SLOT. */\nexport const BODY_SLOT = '<!--@@body@@-->'\n\nexport const esc = (value: unknown): string =>\n String(value ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')\n\nexport function fillMarks(html: string, marks: Record<string, unknown>): string {\n return html.replace(/@@([a-z0-9_]+)@@/gi, (_all, key: string) => esc(marks[key] ?? ''))\n}\n\n/**\n * Compose the body chrome with the page content. The split happens BEFORE any\n * mark filling: fillMarks' @@…@@ pattern would otherwise consume the @@body@@\n * inside the marker comment, leaving <!----> behind and silently dropping the\n * content (measured cost on a real page: 49.8 vs 97.8).\n */\nexport function composeBody(chromeBody: string, marks: Record<string, unknown>, content: string): string {\n return chromeBody\n .split(BODY_SLOT)\n .map((part) => fillMarks(part, marks))\n .join(content)\n}\n\nexport interface MarkablePost {\n slug: string\n title: string\n dates?: string[]\n author?: string\n author_first?: string\n author_last?: string\n terms?: string[]\n featured?: string[]\n excerpt?: string\n}\n\n/** The mark vocabulary the measurement chain proved out: title, author (+ first/last), date{n}, term{n}, feat{n}, excerpt, slug. */\nexport function postMarks(post: MarkablePost): Record<string, string> {\n const marks: Record<string, string> = {\n title: post.title,\n author: post.author ?? '',\n author_first: post.author_first ?? '',\n author_last: post.author_last ?? '',\n excerpt: post.excerpt ?? '',\n slug: post.slug,\n feat: post.featured?.[0] ?? '',\n }\n for (const [i, d] of (post.dates ?? []).entries()) marks[\\`date\\${i}\\`] = d\n for (const [i, t] of (post.terms ?? []).entries()) marks[\\`term\\${i}\\`] = t\n for (const [i, f] of (post.featured ?? []).entries()) marks[\\`feat\\${i}\\`] = f\n return marks\n}\n`\n","// Layout families → Astro layouts.\n//\n// Chrome travels as DATA, not as Astro template source: the compiler must\n// never parse browser-tolerated theme markup. And the body chrome is injected\n// as ONE fragment: real themes nest the content container deep inside the\n// chrome, so splitting it into before/after halves produces unbalanced\n// fragments that the parser silently \"repairs\" (measured cost: 36 vs 100).\n// Content splices in at CHROME_BODY_SLOT before the single injection.\n\nimport type { LayoutFamily } from '@contentrain/types'\nimport { CHROME_BODY_SLOT } from '@contentrain/types'\nimport { pascalCase, stableJson } from './util.js'\n\nexport interface FamilyGenResult {\n files: Record<string, string>\n warnings: string[]\n}\n\nexport function familyFiles(family: LayoutFamily, lang: string): FamilyGenResult {\n const name = pascalCase(family.id)\n const chunks = family.chrome ?? []\n const warnings: string[] = []\n const joined = (position: string) =>\n chunks.filter((c) => c.position === position).map((c) => c.html).join('\\n')\n\n const bodyChunks = chunks.filter((c) => c.position === 'body')\n let body: string\n if (bodyChunks.length) {\n body = bodyChunks.map((c) => c.html).join('\\n')\n if (!body.includes(CHROME_BODY_SLOT)) {\n warnings.push(`family ${family.id}: body chrome has no ${CHROME_BODY_SLOT} marker — content appended at the end`)\n body += CHROME_BODY_SLOT\n }\n } else {\n // Legacy pair: compose into one string with the slot between the halves.\n body = `${joined('before_body')}${CHROME_BODY_SLOT}${joined('after_body')}`\n }\n\n const files: Record<string, string> = {}\n files[`src/data/chrome/${family.id}.json`] = stableJson({\n head: joined('head'),\n body,\n })\n\n const cssLinks = (family.css.files ?? [])\n .map((f) => `<link rel=\"stylesheet\" href=\"/styles/legacy/${f.split('/').pop()}\" />`)\n .join('\\n')\n\n files[`src/layouts/${name}.astro`] = `---\n// Family: ${family.id}${family.name ? ` (${family.name})` : ''} — emitted by @contentrain/emitter-astro\nimport chrome from '../data/chrome/${family.id}.json'\nimport { fillMarks, composeBody } from '../lib/fill'\n\ninterface Props {\n title?: string\n marks?: Record<string, string>\n /** Page content as an HTML string; slot children are used when absent. */\n body?: string\n}\nconst { title = '', marks = {}, body } = Astro.props\nconst head = fillMarks(chrome.head, marks)\nconst content = body ?? (Astro.slots.has('default') ? await Astro.slots.render('default') : '')\n// Split at the marker FIRST, then fill marks per side — filling first would\n// eat the @@body@@ inside the marker and silently drop the content.\nconst html = composeBody(chrome.body, marks, content)\n---\n<!doctype html>\n<html lang=${JSON.stringify(lang)}>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />\n${cssLinks\n .split('\\n')\n .filter(Boolean)\n .map((l) => ` ${l}`)\n .join('\\n')}\n <Fragment set:html={head} />\n <title>{title}</title>\n </head>\n <body>\n <Fragment set:html={html} />\n </body>\n</html>\n`\n return { files, warnings }\n}\n","// Routes → Astro pages.\n//\n// Three shapes, matching what a migrated site actually needs:\n// - `single`: one page per post, body injected with `set:html` inside the family layout.\n// - list kinds (`archive`/`term`/`author`/`date`/`front` with a query): static\n// paths come from the producer's query data; items render through the\n// extracted item template when one exists.\n// - static kinds (no query): the family chrome IS the page.\n//\n// Pagination is a route parameter (`/news/page/:page`), never a separate\n// family — the generated paths simply include the page number in params.\n\nimport type { RouteModel, LayoutFamily } from '@contentrain/types'\nimport type { EmitContent, QueryPage } from './types.js'\nimport { pascalCase, patternToPagePath, stableJson } from './util.js'\n\nexport interface PageGenResult {\n files: Record<string, string>\n warnings: string[]\n}\n\nexport function routeFiles(\n route: RouteModel,\n family: LayoutFamily | undefined,\n content: EmitContent,\n): PageGenResult {\n const warnings: string[] = []\n const files: Record<string, string> = {}\n const pagePath = patternToPagePath(route.pattern)\n if (!pagePath) {\n return { files, warnings: [`route ${route.id}: pattern \"${route.pattern}\" cannot be expressed as an Astro page — skipped`] }\n }\n if (!family) {\n return { files, warnings: [`route ${route.id}: family \"${route.family}\" not found — skipped`] }\n }\n const layout = pascalCase(family.id)\n const depth = pagePath.split('/').length - 1\n const up = '../'.repeat(depth + 1) || '../'\n const hasParams = pagePath.includes('[')\n\n if (route.kind === 'single') {\n const posts = content.posts ?? []\n if (!posts.length) warnings.push(`route ${route.id}: single route with no posts — page emitted, data file empty`)\n files['src/data/posts.json'] = stableJson(posts)\n files[`src/pages/${pagePath}`] = singlePage(route, layout, up)\n return { files, warnings }\n }\n\n const queryPages: QueryPage[] = route.query ? (content.queries?.[route.query] ?? []) : []\n if (route.query) {\n if (!queryPages.length) warnings.push(`route ${route.id}: query \"${route.query}\" has no data — page emitted, data file empty`)\n if (queryPages.some((p) => !p.item_template)) {\n warnings.push(`route ${route.id}: item template missing on some pages — plain fallback list rendered (not fidelity)`)\n }\n files[`src/data/queries/${route.query}.json`] = stableJson(queryPages)\n files[`src/pages/${pagePath}`] = listPage(route, layout, up, hasParams)\n return { files, warnings }\n }\n\n files[`src/pages/${pagePath}`] = staticPage(route, layout, up, hasParams, warnings)\n return { files, warnings }\n}\n\nfunction singlePage(route: RouteModel, layout: string, up: string): string {\n return `---\n// Route: ${route.id} (${route.pattern}) — emitted by @contentrain/emitter-astro\nimport Layout from '${up}layouts/${layout}.astro'\nimport posts from '${up}data/posts.json'\nimport { postMarks } from '${up}lib/fill'\n\nexport function getStaticPaths() {\n return posts.map((post) => ({ params: { slug: post.slug }, props: { post } }))\n}\ntype Props = { post: (typeof posts)[number] }\nconst { post } = Astro.props as Props\n---\n<Layout title={post.title} marks={postMarks(post)} body={post.body} />\n`\n}\n\nfunction listPage(route: RouteModel, layout: string, up: string, hasParams: boolean): string {\n const paths = hasParams\n ? `export function getStaticPaths() {\n return pages.map((page) => ({ params: page.params, props: { page } }))\n}\ntype Props = { page: (typeof pages)[number] }\nconst { page } = Astro.props as Props`\n : `const page = pages[0] ?? { params: {}, items: [] }`\n return `---\n// Route: ${route.id} (${route.pattern}) — emitted by @contentrain/emitter-astro\nimport Layout from '${up}layouts/${layout}.astro'\nimport pages from '${up}data/queries/${route.query}.json'\nimport { esc, fillMarks, postMarks } from '${up}lib/fill'\n\n${paths}\nconst items = page.items.map((item) =>\n page.item_template ? fillMarks(page.item_template, postMarks(item)) : undefined,\n)\nconst fallback = items.some((h) => h === undefined)\nconst content = fallback\n ? '<ul class=\"cr-post-list\">' +\n page.items.map((item) => '<li><a href=\"/' + item.slug + '/\">' + esc(item.title) + '</a></li>').join('') +\n '</ul>'\n : items.join('')\n---\n<Layout title={page.params.term ?? ''} marks={page.params} body={content} />\n`\n}\n\nfunction staticPage(route: RouteModel, layout: string, up: string, hasParams: boolean, warnings: string[]): string {\n if (hasParams) warnings.push(`route ${route.id}: parameterized route without a query — emitted with empty paths`)\n const paths = hasParams\n ? `export function getStaticPaths() {\n return []\n}\n`\n : ''\n return `---\n// Route: ${route.id} (${route.pattern}) — emitted by @contentrain/emitter-astro\nimport Layout from '${up}layouts/${layout}.astro'\n${paths}---\n<Layout title=\"\" marks={{}} />\n`\n}\n","// Component placeholders.\n//\n// The emitter cannot invent a comments form or an ad slot — it marks the\n// spot. `rest`-sourced components are candidates for real implementations\n// against content data; `runtime` components need a live provider (that\n// conversation belongs to MigrationHandoff offers); `chrome` components\n// already travel inside the family chrome and get a stub for refactoring\n// toward.\n\nimport type { ComponentDef } from '@contentrain/types'\nimport { pascalCase } from './util.js'\n\nexport function componentFiles(components: ComponentDef[]): Record<string, string> {\n const files: Record<string, string> = {}\n for (const c of components) {\n const variants = (c.variants ?? []).map((v) => v.key)\n files[`src/components/${pascalCase(c.id)}.astro`] = `---\n/**\n * cr-component: type=${c.type} source=${c.source}${c.name ? ` — ${c.name}` : ''}\n * Emitted by @contentrain/emitter-astro as a placeholder.${\n c.source === 'runtime' ? '\\n * Needs a live provider — see the migration handoff offers.' : ''\n }${variants.length ? `\\n * Variants: ${variants.join(', ')}` : ''}\n */\ninterface Props {\n variant?: string\n}\nconst { variant = ${JSON.stringify(variants[0] ?? 'default')} } = Astro.props\n---\n<cr-component data-type=${JSON.stringify(c.type)} data-variant={variant}></cr-component>\n`\n }\n return files\n}\n","// Legacy CSS quarantine (the fidelity layer).\n//\n// Migrated pages must render pixel-identically, and a utility framework's\n// preflight/reset would fight the theme's CSS. The truce is a cascade layer:\n// every legacy stylesheet is wrapped in `@layer legacy { … }`, and modern CSS\n// lives in its own layer — the two never meet in specificity.\n//\n// One CSS rule constrains the wrapping: `@import` (and `@charset`) must\n// precede all other statements, so a file cannot simply be wrapped whole.\n// Leading imports are hoisted above the wrapper and given `layer(legacy)`;\n// an import *after* other rules is already invalid CSS that browsers ignore,\n// so the file is left unwrapped and a warning recorded instead of silently\n// producing different invalidity.\n\nimport { LEGACY_CSS_LAYER } from '@contentrain/types'\n\nexport interface WrapCssResult {\n content: string\n warning?: string\n}\n\nconst LEADING = /^(\\s*(?:@charset[^;]+;|@import[^;]+;|\\/\\*[\\s\\S]*?\\*\\/)\\s*)+/\n\nexport function wrapLegacyCss(path: string, css: string): WrapCssResult {\n const rest = css.replace(LEADING, '')\n if (/@import\\s/.test(rest)) {\n return {\n content: css,\n warning: `${path}: @import after other rules — left unwrapped (fix the source stylesheet; mid-file imports are ignored by browsers)`,\n }\n }\n const leading = css.slice(0, css.length - rest.length)\n const hoisted = leading.replace(/@import\\s+([^;]+);/g, (full, spec: string) =>\n /\\blayer\\s*\\(/.test(spec) ? full : `@import ${spec.trim()} layer(${LEGACY_CSS_LAYER});`,\n )\n return { content: `${hoisted}@layer ${LEGACY_CSS_LAYER} {\\n${rest}\\n}\\n` }\n}\n","// @contentrain/emitter-astro — the open half of the migration pipeline.\n//\n// A ProjectIR (route model, layout families, component variants, query\n// bindings, design tokens) plus prepared content goes in; a complete Astro\n// project comes out as a pure file map. The analysis that *produces* a good\n// ProjectIR is hard and lives elsewhere; rendering one is deliberately\n// boring — which is exactly why it can be open, portable, and replaceable\n// by community emitters for other frameworks.\n\nimport type { EmitInput, EmitResult } from './types.js'\nimport { scaffoldFiles } from './scaffold.js'\nimport { familyFiles } from './layouts.js'\nimport { routeFiles } from './pages.js'\nimport { componentFiles } from './components.js'\nimport { wrapLegacyCss } from './css.js'\n\nexport function emitAstroProject(input: EmitInput): EmitResult {\n const { ir } = input\n const warnings: string[] = []\n const files: Record<string, string> = {}\n const add = (batch: Record<string, string>) => {\n for (const [path, content] of Object.entries(batch)) {\n if (files[path] !== undefined && files[path] !== content) {\n warnings.push(`duplicate file with different content: ${path} — keeping the first`)\n continue\n }\n files[path] = content\n }\n }\n\n add(scaffoldFiles(ir, input.options ?? {}))\n\n const familiesById = new Map(ir.families.map((f) => [f.id, f]))\n const lang = ir.site.locales?.[0] ?? 'en'\n for (const family of ir.families) {\n const fam = familyFiles(family, lang)\n add(fam.files)\n warnings.push(...fam.warnings)\n }\n\n for (const css of input.css ?? []) {\n const wrapped = wrapLegacyCss(css.path, css.content)\n if (wrapped.warning) warnings.push(wrapped.warning)\n const base = css.path.split('/').pop() ?? css.path\n add({ [`public/styles/legacy/${base}`]: wrapped.content })\n }\n for (const family of ir.families) {\n for (const ref of family.css.files ?? []) {\n const base = ref.split('/').pop()\n if (!(input.css ?? []).some((c) => (c.path.split('/').pop() ?? c.path) === base)) {\n warnings.push(`family ${family.id}: css file \"${ref}\" not provided in input.css`)\n }\n }\n }\n\n for (const route of ir.routes) {\n const result = routeFiles(route, familiesById.get(route.family), input.content ?? {})\n add(result.files)\n warnings.push(...result.warnings)\n }\n\n add(componentFiles(ir.components ?? []))\n\n return { files, warnings }\n}\n\n/** Write an EmitResult to disk. Separate from emit so the core stays pure. */\nexport async function writeEmit(result: EmitResult, dir: string): Promise<void> {\n const { mkdir, writeFile } = await import('node:fs/promises')\n const { dirname, join } = await import('node:path')\n const dirs = new Set(Object.keys(result.files).map((p) => dirname(join(dir, p))))\n await Promise.all([...dirs].map((d) => mkdir(d, { recursive: true })))\n await Promise.all(\n Object.entries(result.files).map(([path, content]) => writeFile(join(dir, path), content, 'utf8')),\n )\n}\n\nexport type {\n EmitInput,\n EmitResult,\n EmitContent,\n EmitPost,\n QueryPage,\n EmitCssFile,\n EmitOptions,\n} from './types.js'\nexport { wrapLegacyCss } from './css.js'\nexport { pascalCase, patternToPagePath, stableJson } from './util.js'\n"],"mappings":";;;AACA,SAAgB,WAAW,IAAoB;AAC7C,QAAO,GACJ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C,KAAK;AACjC,MAAI,EAAE,MAAM,OAAO,EAAE,EAAE,MAAM,OAAO,EAAE,KAAK,MAAM,IAAI,CAAC,KAAK,IAAI,EAAE,UAAU,KAAK,CAC9E,UAAS,KAAK,UAAU,OAAO,GAAG,cAAc,IAAI,6BAA6B;;AAKvF,MAAK,MAAM,SAAS,GAAG,QAAQ;EAC7B,MAAM,SAAS,WAAW,OAAO,aAAa,IAAI,MAAM,OAAO,EAAE,MAAM,WAAW,EAAE,CAAC;AACrF,MAAI,OAAO,MAAM;AACjB,WAAS,KAAK,GAAG,OAAO,SAAS;;AAGnC,KAAI,eAAe,GAAG,cAAc,EAAE,CAAC,CAAC;AAExC,QAAO;EAAE;EAAO;EAAU;;;AAI5B,eAAsB,UAAU,QAAoB,KAA4B;CAC9E,MAAM,EAAE,OAAO,cAAc,MAAM,OAAO;CAC1C,MAAM,EAAE,SAAS,SAAS,MAAM,OAAO;CACvC,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,OAAO,MAAM,CAAC,KAAK,MAAM,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC;AACjF,OAAM,QAAQ,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,MAAM,MAAM,GAAG,EAAE,WAAW,MAAM,CAAC,CAAC,CAAC;AACtE,OAAM,QAAQ,IACZ,OAAO,QAAQ,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,aAAa,UAAU,KAAK,KAAK,KAAK,EAAE,SAAS,OAAO,CAAC,CACnG"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/util.ts","../src/scaffold.ts","../src/layouts.ts","../src/pages.ts","../src/components.ts","../src/css.ts","../src/index.ts"],"sourcesContent":["/** \"f-archive\" → \"FArchive\", \"posts\" → \"Posts\" — Astro component file names. */\nexport function pascalCase(id: string): string {\n return id\n .split(/[^a-zA-Z0-9]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')\n}\n\n/**\n * Route pattern → Astro pages path.\n * `/` → `index.astro`; `/category/:term/page/:page` → `category/[term]/page/[page].astro`.\n * Returns null for patterns Astro's file routing cannot express (recorded as a warning upstream).\n */\nexport function patternToPagePath(pattern: string): string | null {\n if (pattern === '/' || pattern === '') return 'index.astro'\n if (pattern.includes('*')) return null\n const segments = pattern.replace(/^\\/+|\\/+$/g, '').split('/')\n const mapped = segments.map((seg) => (seg.startsWith(':') ? `[${seg.slice(1)}]` : seg))\n if (mapped.some((seg) => !/^[[\\]a-zA-Z0-9._-]+$/.test(seg))) return null\n const last = mapped.pop()\n return [...mapped, `${last}.astro`].join('/')\n}\n\nconst sortDeep = (v: unknown): unknown => {\n if (Array.isArray(v)) return v.map(sortDeep)\n if (v && typeof v === 'object') {\n return Object.fromEntries(\n Object.entries(v as Record<string, unknown>)\n .toSorted(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, val]) => [k, sortDeep(val)]),\n )\n }\n return v\n}\n\n/** JSON with stable key order and trailing newline — deterministic output, stable diffs. */\nexport function stableJson(value: unknown): string {\n return `${JSON.stringify(sortDeep(value), null, 2)}\\n`\n}\n","// Project scaffolding: manifest, config, styles, and the shared fill helper\n// the generated pages use to pour content into `@@mark@@` placeholders.\n\nimport type { DesignTokens, ProjectIR } from '@contentrain/types'\nimport type { EmitOptions } from './types.js'\nimport { stableJson } from './util.js'\n\nexport function scaffoldFiles(ir: ProjectIR, options: EmitOptions): Record<string, string> {\n const tailwind = options.tailwind !== false\n const split = ir.viewport_strategy === 'split'\n const files: Record<string, string> = {}\n\n const pkg: Record<string, unknown> = {\n name: options.projectName ?? 'migrated-site',\n private: true,\n type: 'module',\n scripts: {\n dev: 'astro dev',\n // `astro check` first: type errors in generated pages should fail the\n // build, not surface later in a browser.\n build: 'astro check && astro build',\n preview: 'astro preview',\n // Split viewport production (skeleton): one build per device class, served by device.\n ...(split ? { 'build:desktop': 'VIEWPORT=desktop astro build --outDir dist/desktop', 'build:mobile': 'VIEWPORT=mobile astro build --outDir dist/mobile' } : {}),\n },\n dependencies: {\n astro: '^5.0.0',\n ...(tailwind ? { tailwindcss: '^4.0.0', '@tailwindcss/vite': '^4.0.0' } : {}),\n },\n devDependencies: {\n '@astrojs/check': '^0.9.0',\n typescript: '^5.7.0',\n },\n }\n files['package.json'] = stableJson(pkg)\n\n files['astro.config.mjs'] = [\n `import { defineConfig } from 'astro/config'`,\n ...(tailwind ? [`import tailwindcss from '@tailwindcss/vite'`] : []),\n ``,\n `export default defineConfig({`,\n // Canonical URLs and sitemaps hang off \\`site\\` — for a migration, SEO\n // continuity is the point, so the source site's URL always lands here.\n ` site: ${JSON.stringify(ir.site.url)},`,\n ` build: { format: 'directory' },`,\n ...(tailwind ? [` vite: { plugins: [tailwindcss()] },`] : []),\n `})`,\n ``,\n ].join('\\n')\n\n // Astro wants a tsconfig in every project — editors and the compiler read\n // it even in JS-only projects, and the emitted src/lib/fill.ts is TS.\n files['tsconfig.json'] = `${JSON.stringify({ extends: 'astro/tsconfigs/base', include: ['.astro/types.d.ts', '**/*'], exclude: ['dist'] }, null, 2)}\\n`\n\n if (tailwind) files['src/styles/modern.css'] = modernCss(ir.tokens)\n\n files['src/lib/fill.ts'] = FILL_TS\n return files\n}\n\n/** Tailwind 4 evolution layer: CSS-first config with the site's extracted tokens. */\nfunction modernCss(tokens: DesignTokens | undefined): string {\n const lines: string[] = [`@import 'tailwindcss';`, ``]\n const theme: string[] = []\n const push = (prefix: string, map: Record<string, string> | undefined) => {\n for (const [key, value] of Object.entries(map ?? {})) theme.push(` --${prefix}-${key}: ${value};`)\n }\n push('color', tokens?.colors)\n push('font', tokens?.font_families)\n push('text', tokens?.font_sizes)\n push('spacing', tokens?.spacing)\n push('breakpoint', tokens?.breakpoints)\n if (theme.length) lines.push(`@theme {`, ...theme, `}`)\n return `${lines.join('\\n')}\\n`\n}\n\nconst FILL_TS = `// Emitted by @contentrain/emitter-astro — the template runtime.\n//\n// Chrome, item templates and attribute values carry three marker forms:\n// @@mark@@ — a value, escaped\n// @@mark_html@@ — a value, raw HTML\n// <!--@@repeat:list@@-->…<!--@@/repeat@@--> — once per list item\n// <!--@@if:name@@-->…<!--@@/if@@--> — only when name has a value\n// Rendering order is repeats → conditionals → marks, so a repeat body may hold\n// conditionals and marks that only make sense per item.\n\n/** Where page content splices into the body chrome — must match @contentrain/types CHROME_BODY_SLOT. */\nexport const BODY_SLOT = '<!--@@body@@-->'\n\nconst REPEAT_RE = /<!--@@repeat:([a-z0-9_]+)(?:\\\\|([\\\\s\\\\S]*?))?@@-->([\\\\s\\\\S]*?)<!--@@\\\\/repeat@@-->/gi\nconst IF_RE = /<!--@@if:(!?)([a-z0-9_]+)@@-->([\\\\s\\\\S]*?)<!--@@\\\\/if@@-->/gi\nconst MARK_RE = /@@([a-z0-9_]+)@@/gi\n\nexport type Values = Record<string, unknown>\n\nexport const esc = (value: unknown): string =>\n String(value ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')\n\nconst isFilled = (value: unknown): boolean =>\n Array.isArray(value) ? value.length > 0 : value !== undefined && value !== null && value !== ''\n\n/**\n * Replace @@marks@@. Values are escaped unless the mark name ends in _html —\n * escaping is the default so content-derived text can never break the page,\n * and the _html opt-in exists for themes that print a post's own markup\n * (full content in a list card, a link-bearing excerpt).\n */\nexport function fillMarks(html: string, values: Values): string {\n return html.replace(MARK_RE, (_all, key: string) => {\n const value = values[key]\n if (Array.isArray(value)) return value.map((v) => esc(v)).join(', ')\n return key.toLowerCase().endsWith('_html') ? String(value ?? '') : esc(value ?? '')\n })\n}\n\n/** Expand repeat blocks; each item renders the inner fragment with its own values. */\nexport function expandRepeats(html: string, values: Values): string {\n return html.replace(REPEAT_RE, (_all, name: string, sep: string | undefined, inner: string) => {\n const list = values[name]\n if (!Array.isArray(list) || list.length === 0) return ''\n return list\n .map((item, index) => {\n const itemValues: Values = { ...values, item, item_index: String(index) }\n if (item && typeof item === 'object') {\n for (const [k, v] of Object.entries(item as Record<string, unknown>)) itemValues['item_' + k] = v\n }\n return renderTemplate(inner, itemValues)\n })\n .join(sep ?? '')\n })\n}\n\n/** Drop conditional blocks whose value is empty (or present, when negated). */\nexport function applyConditions(html: string, values: Values): string {\n return html.replace(IF_RE, (_all, negate: string, name: string, inner: string) =>\n isFilled(values[name]) !== (negate === '!') ? inner : '',\n )\n}\n\n/** Full render: repeats → conditionals → marks. */\nexport function renderTemplate(html: string, values: Values): string {\n return fillMarks(applyConditions(expandRepeats(html, values), values), values)\n}\n\n/** Fill marks inside attribute values (per-page classes like postid-123). */\nexport function fillAttrs(attrs: Record<string, string> | undefined, values: Values): Record<string, string> {\n const out: Record<string, string> = {}\n for (const [name, value] of Object.entries(attrs ?? {})) out[name] = fillMarks(value, values)\n return out\n}\n\n/**\n * Compose the body chrome with the page content. The split happens BEFORE any\n * rendering: the @@…@@ pattern would otherwise consume the @@body@@ inside the\n * marker comment, leaving <!----> behind and silently dropping the content\n * (measured cost on a real page: 49.8 vs 97.8).\n */\nexport function composeBody(chromeBody: string, values: Values, content: string): string {\n return chromeBody\n .split(BODY_SLOT)\n .map((part) => renderTemplate(part, values))\n .join(content)\n}\n\n/** Emitted stylesheets live under /styles/legacy/ — pages reference them by file name. */\nexport const cssHref = (file: string): string => '/styles/legacy/' + (file.split('/').pop() ?? file)\n\nexport interface MarkablePost {\n slug: string\n title: string\n body?: string\n dates?: string[]\n author?: string\n author_first?: string\n author_last?: string\n authors?: string[]\n terms?: string[]\n featured?: string[]\n excerpt?: string\n excerpt_html?: string\n marks?: Record<string, unknown>\n}\n\n/**\n * The mark vocabulary: title, author (+ first/last), date{n}, term{n}, feat{n},\n * excerpt, slug — plus \\`terms\\`/\\`authors\\` as LISTS for repeat blocks, the\n * _html variants for raw insertion, and any producer-supplied extras.\n */\nexport function postMarks(post: MarkablePost): Values {\n const values: Values = {\n title: post.title,\n author: post.author ?? '',\n author_first: post.author_first ?? '',\n author_last: post.author_last ?? '',\n excerpt: post.excerpt ?? '',\n excerpt_html: post.excerpt_html ?? post.excerpt ?? '',\n body_html: post.body ?? '',\n slug: post.slug,\n feat: post.featured?.[0] ?? '',\n terms: post.terms ?? [],\n authors: post.authors ?? (post.author ? [post.author] : []),\n }\n for (const [i, d] of (post.dates ?? []).entries()) values['date' + i] = d\n for (const [i, t] of (post.terms ?? []).entries()) values['term' + i] = t\n for (const [i, f] of (post.featured ?? []).entries()) values['feat' + i] = f\n return { ...values, ...(post.marks ?? {}) }\n}\n`\n","// Layout families → Astro layouts.\n//\n// Chrome travels as DATA, not as Astro template source: the compiler must\n// never parse browser-tolerated theme markup. And the body chrome is injected\n// as ONE fragment: real themes nest the content container deep inside the\n// chrome, so splitting it into before/after halves produces unbalanced\n// fragments that the parser silently \"repairs\" (measured cost: 36 vs 100).\n// Content splices in at CHROME_BODY_SLOT before the single injection.\n//\n// Root attributes travel with the chrome for the same reason: themes key their\n// container rules off `<body class=\"wp-singular single …\">` and `<html class=\"js\n// wf-…\">`, so a page with perfect content and empty root attributes loses its\n// whole layout (measured: 36.4 vs 100).\n\nimport type { LayoutFamily } from '@contentrain/types'\nimport { CHROME_BODY_SLOT } from '@contentrain/types'\nimport { pascalCase, stableJson } from './util.js'\n\nexport interface FamilyGenResult {\n files: Record<string, string>\n warnings: string[]\n}\n\nexport function familyFiles(family: LayoutFamily, lang: string): FamilyGenResult {\n const name = pascalCase(family.id)\n const chunks = family.chrome ?? []\n const warnings: string[] = []\n const joined = (position: string) =>\n chunks.filter((c) => c.position === position).map((c) => c.html).join('\\n')\n\n const bodyChunks = chunks.filter((c) => c.position === 'body')\n let body: string\n if (bodyChunks.length) {\n body = bodyChunks.map((c) => c.html).join('\\n')\n if (!body.includes(CHROME_BODY_SLOT)) {\n warnings.push(`family ${family.id}: body chrome has no ${CHROME_BODY_SLOT} marker — content appended at the end`)\n body += CHROME_BODY_SLOT\n }\n } else {\n // Legacy pair: compose into one string with the slot between the halves.\n body = `${joined('before_body')}${CHROME_BODY_SLOT}${joined('after_body')}`\n }\n\n const files: Record<string, string> = {}\n files[`src/data/chrome/${family.id}.json`] = stableJson({\n head: joined('head'),\n body,\n html_attrs: family.root_attrs?.html ?? {},\n body_attrs: family.root_attrs?.body ?? {},\n })\n\n const cssLinks = (family.css.files ?? [])\n .map((f) => `<link rel=\"stylesheet\" href=\"/styles/legacy/${f.split('/').pop()}\" />`)\n .join('\\n')\n\n files[`src/layouts/${name}.astro`] = `---\n// Family: ${family.id}${family.name ? ` (${family.name})` : ''} — emitted by @contentrain/emitter-astro\nimport chrome from '../data/chrome/${family.id}.json'\nimport { cssHref, fillAttrs, renderTemplate, composeBody } from '../lib/fill'\n\ninterface Props {\n title?: string\n marks?: Record<string, unknown>\n /** Page content as an HTML string; slot children are used when absent. */\n body?: string\n /** Stylesheets only this page loads (page-builder sites emit CSS per page). */\n css?: string[]\n}\nconst { title = '', marks = {}, body, css = [] } = Astro.props\nconst head = renderTemplate(chrome.head, marks)\n// Root attributes carry the theme's layout hooks; values may hold @@marks@@.\n// An explicit lang from the source wins over the project default.\nconst htmlAttrs = { lang: ${JSON.stringify(lang)}, ...fillAttrs(chrome.html_attrs, marks) }\nconst bodyAttrs = fillAttrs(chrome.body_attrs, marks)\nconst content = body ?? (Astro.slots.has('default') ? await Astro.slots.render('default') : '')\n// Split at the marker FIRST, then fill marks per side — filling first would\n// eat the @@body@@ inside the marker and silently drop the content.\nconst html = composeBody(chrome.body, marks, content)\n---\n<!doctype html>\n<html {...htmlAttrs}>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />\n${cssLinks\n .split('\\n')\n .filter(Boolean)\n .map((l) => ` ${l}`)\n .join('\\n')}\n {css.map((file) => (\n <link rel=\"stylesheet\" href={cssHref(file)} />\n ))}\n <Fragment set:html={head} />\n <title>{title}</title>\n </head>\n <body {...bodyAttrs}>\n <Fragment set:html={html} />\n </body>\n</html>\n`\n return { files, warnings }\n}\n","// Routes → Astro pages.\n//\n// Three shapes, matching what a migrated site actually needs:\n// - `single`: one page per post, body injected with `set:html` inside the family layout.\n// - list kinds (`archive`/`term`/`author`/`date`/`front` with a query): static\n// paths come from the producer's query data; items render through the\n// extracted item template when one exists.\n// - static kinds (no query): the family chrome IS the page.\n//\n// Pagination is a route parameter (`/news/page/:page`), never a separate\n// family — the generated paths simply include the page number in params.\n\nimport type { RouteModel, LayoutFamily } from '@contentrain/types'\nimport type { EmitContent, QueryPage } from './types.js'\nimport { pascalCase, patternToPagePath, stableJson } from './util.js'\n\nexport interface PageGenResult {\n files: Record<string, string>\n warnings: string[]\n}\n\nexport function routeFiles(\n route: RouteModel,\n family: LayoutFamily | undefined,\n content: EmitContent,\n): PageGenResult {\n const warnings: string[] = []\n const files: Record<string, string> = {}\n const pagePath = patternToPagePath(route.pattern)\n if (!pagePath) {\n return { files, warnings: [`route ${route.id}: pattern \"${route.pattern}\" cannot be expressed as an Astro page — skipped`] }\n }\n if (!family) {\n return { files, warnings: [`route ${route.id}: family \"${route.family}\" not found — skipped`] }\n }\n const layout = pascalCase(family.id)\n const depth = pagePath.split('/').length - 1\n const up = '../'.repeat(depth + 1) || '../'\n const hasParams = pagePath.includes('[')\n\n if (route.kind === 'single') {\n const posts = content.posts ?? []\n if (!posts.length) warnings.push(`route ${route.id}: single route with no posts — page emitted, data file empty`)\n files['src/data/posts.json'] = stableJson(posts)\n files[`src/pages/${pagePath}`] = singlePage(route, layout, up)\n return { files, warnings }\n }\n\n const queryPages: QueryPage[] = route.query ? (content.queries?.[route.query] ?? []) : []\n if (route.query) {\n if (!queryPages.length) warnings.push(`route ${route.id}: query \"${route.query}\" has no data — page emitted, data file empty`)\n if (queryPages.some((p) => !p.item_template)) {\n warnings.push(`route ${route.id}: item template missing on some pages — plain fallback list rendered (not fidelity)`)\n }\n files[`src/data/queries/${route.query}.json`] = stableJson(queryPages)\n files[`src/pages/${pagePath}`] = listPage(route, layout, up, hasParams)\n return { files, warnings }\n }\n\n files[`src/pages/${pagePath}`] = staticPage(route, layout, up, hasParams, warnings)\n return { files, warnings }\n}\n\nfunction singlePage(route: RouteModel, layout: string, up: string): string {\n return `---\n// Route: ${route.id} (${route.pattern}) — emitted by @contentrain/emitter-astro\nimport Layout from '${up}layouts/${layout}.astro'\nimport posts from '${up}data/posts.json'\nimport { postMarks } from '${up}lib/fill'\n\nexport function getStaticPaths() {\n // A post carries its own route parameters (date parts of a dated permalink,\n // a post id) — using the template post's would send every other post to the\n // wrong address.\n return posts.map((post) => ({ params: { ...(post.params ?? {}), slug: post.slug }, props: { post } }))\n}\ntype Props = { post: (typeof posts)[number] }\nconst { post } = Astro.props as Props\n---\n<Layout title={post.title} marks={postMarks(post)} body={post.body} css={post.css ?? []} />\n`\n}\n\nfunction listPage(route: RouteModel, layout: string, up: string, hasParams: boolean): string {\n const paths = hasParams\n ? `export function getStaticPaths() {\n return pages.map((page) => ({ params: page.params, props: { page } }))\n}\ntype Props = { page: (typeof pages)[number] }\nconst { page } = Astro.props as Props`\n : `const page = pages[0] ?? { params: {}, items: [] }`\n return `---\n// Route: ${route.id} (${route.pattern}) — emitted by @contentrain/emitter-astro\nimport Layout from '${up}layouts/${layout}.astro'\nimport pages from '${up}data/queries/${route.query}.json'\nimport { esc, postMarks, renderTemplate } from '${up}lib/fill'\n\n${paths}\nconst items = page.items.map((item) =>\n page.item_template ? renderTemplate(page.item_template, postMarks(item)) : undefined,\n)\nconst fallback = items.some((h) => h === undefined)\nconst content = fallback\n ? '<ul class=\"cr-post-list\">' +\n page.items.map((item) => '<li><a href=\"/' + item.slug + '/\">' + esc(item.title) + '</a></li>').join('') +\n '</ul>'\n : items.join('')\n// Route params carry slugs; page marks carry what the chrome needs to SHOW\n// (a term's display name, description, count).\nconst marks = { ...page.params, ...(page.marks ?? {}) }\n---\n<Layout title={String(marks.term_name ?? page.params.term ?? '')} marks={marks} body={content} css={page.css ?? []} />\n`\n}\n\nfunction staticPage(route: RouteModel, layout: string, up: string, hasParams: boolean, warnings: string[]): string {\n if (hasParams) warnings.push(`route ${route.id}: parameterized route without a query — emitted with empty paths`)\n const paths = hasParams\n ? `export function getStaticPaths() {\n return []\n}\n`\n : ''\n return `---\n// Route: ${route.id} (${route.pattern}) — emitted by @contentrain/emitter-astro\nimport Layout from '${up}layouts/${layout}.astro'\n${paths}---\n<Layout title=\"\" marks={{}} />\n`\n}\n","// Component placeholders.\n//\n// The emitter cannot invent a comments form or an ad slot — it marks the\n// spot. `rest`-sourced components are candidates for real implementations\n// against content data; `runtime` components need a live provider (that\n// conversation belongs to MigrationHandoff offers); `chrome` components\n// already travel inside the family chrome and get a stub for refactoring\n// toward.\n\nimport type { ComponentDef } from '@contentrain/types'\nimport { pascalCase } from './util.js'\n\nexport function componentFiles(components: ComponentDef[]): Record<string, string> {\n const files: Record<string, string> = {}\n for (const c of components) {\n const variants = (c.variants ?? []).map((v) => v.key)\n files[`src/components/${pascalCase(c.id)}.astro`] = `---\n/**\n * cr-component: type=${c.type} source=${c.source}${c.name ? ` — ${c.name}` : ''}\n * Emitted by @contentrain/emitter-astro as a placeholder.${\n c.source === 'runtime' ? '\\n * Needs a live provider — see the migration handoff offers.' : ''\n }${variants.length ? `\\n * Variants: ${variants.join(', ')}` : ''}\n */\ninterface Props {\n variant?: string\n}\nconst { variant = ${JSON.stringify(variants[0] ?? 'default')} } = Astro.props\n---\n<cr-component data-type=${JSON.stringify(c.type)} data-variant={variant}></cr-component>\n`\n }\n return files\n}\n","// Legacy CSS quarantine (the fidelity layer).\n//\n// Migrated pages must render pixel-identically, and a utility framework's\n// preflight/reset would fight the theme's CSS. The truce is a cascade layer:\n// every legacy stylesheet is wrapped in `@layer legacy { … }`, and modern CSS\n// lives in its own layer — the two never meet in specificity.\n//\n// One CSS rule constrains the wrapping: `@import` (and `@charset`) must\n// precede all other statements, so a file cannot simply be wrapped whole.\n// Leading imports are hoisted above the wrapper and given `layer(legacy)`;\n// an import *after* other rules is already invalid CSS that browsers ignore,\n// so the file is left unwrapped and a warning recorded instead of silently\n// producing different invalidity.\n\nimport { LEGACY_CSS_LAYER } from '@contentrain/types'\n\nexport interface WrapCssResult {\n content: string\n warning?: string\n}\n\nconst LEADING = /^(\\s*(?:@charset[^;]+;|@import[^;]+;|\\/\\*[\\s\\S]*?\\*\\/)\\s*)+/\n\nexport function wrapLegacyCss(path: string, css: string): WrapCssResult {\n const rest = css.replace(LEADING, '')\n if (/@import\\s/.test(rest)) {\n return {\n content: css,\n warning: `${path}: @import after other rules — left unwrapped (fix the source stylesheet; mid-file imports are ignored by browsers)`,\n }\n }\n const leading = css.slice(0, css.length - rest.length)\n const hoisted = leading.replace(/@import\\s+([^;]+);/g, (full, spec: string) =>\n /\\blayer\\s*\\(/.test(spec) ? full : `@import ${spec.trim()} layer(${LEGACY_CSS_LAYER});`,\n )\n return { content: `${hoisted}@layer ${LEGACY_CSS_LAYER} {\\n${rest}\\n}\\n` }\n}\n","// @contentrain/emitter-astro — the open half of the migration pipeline.\n//\n// A ProjectIR (route model, layout families, component variants, query\n// bindings, design tokens) plus prepared content goes in; a complete Astro\n// project comes out as a pure file map. The analysis that *produces* a good\n// ProjectIR is hard and lives elsewhere; rendering one is deliberately\n// boring — which is exactly why it can be open, portable, and replaceable\n// by community emitters for other frameworks.\n\nimport type { EmitInput, EmitResult } from './types.js'\nimport { scaffoldFiles } from './scaffold.js'\nimport { familyFiles } from './layouts.js'\nimport { routeFiles } from './pages.js'\nimport { componentFiles } from './components.js'\nimport { wrapLegacyCss } from './css.js'\n\nexport function emitAstroProject(input: EmitInput): EmitResult {\n const { ir } = input\n const warnings: string[] = []\n const files: Record<string, string> = {}\n const add = (batch: Record<string, string>) => {\n for (const [path, content] of Object.entries(batch)) {\n if (files[path] !== undefined && files[path] !== content) {\n warnings.push(`duplicate file with different content: ${path} — keeping the first`)\n continue\n }\n files[path] = content\n }\n }\n\n add(scaffoldFiles(ir, input.options ?? {}))\n\n const familiesById = new Map(ir.families.map((f) => [f.id, f]))\n const lang = ir.site.locales?.[0] ?? 'en'\n for (const family of ir.families) {\n const fam = familyFiles(family, lang)\n add(fam.files)\n warnings.push(...fam.warnings)\n }\n\n for (const css of input.css ?? []) {\n const wrapped = wrapLegacyCss(css.path, css.content)\n if (wrapped.warning) warnings.push(wrapped.warning)\n const base = css.path.split('/').pop() ?? css.path\n add({ [`public/styles/legacy/${base}`]: wrapped.content })\n }\n const providedCss = new Set((input.css ?? []).map((c) => c.path.split('/').pop() ?? c.path))\n const missingCss = (refs: string[] | undefined, owner: string) => {\n for (const ref of refs ?? []) {\n if (!providedCss.has(ref.split('/').pop() ?? ref)) {\n warnings.push(`${owner}: css file \"${ref}\" not provided in input.css`)\n }\n }\n }\n for (const family of ir.families) missingCss(family.css.files, `family ${family.id}`)\n for (const post of input.content?.posts ?? []) missingCss(post.css, `post ${post.slug}`)\n for (const [queryId, queryPages] of Object.entries(input.content?.queries ?? {})) {\n for (const qp of queryPages) missingCss(qp.css, `query ${queryId}`)\n }\n\n for (const route of ir.routes) {\n const result = routeFiles(route, familiesById.get(route.family), input.content ?? {})\n add(result.files)\n warnings.push(...result.warnings)\n }\n\n add(componentFiles(ir.components ?? []))\n\n return { files, warnings }\n}\n\n/** Write an EmitResult to disk. Separate from emit so the core stays pure. */\nexport async function writeEmit(result: EmitResult, dir: string): Promise<void> {\n const { mkdir, writeFile } = await import('node:fs/promises')\n const { dirname, join } = await import('node:path')\n const dirs = new Set(Object.keys(result.files).map((p) => dirname(join(dir, p))))\n await Promise.all([...dirs].map((d) => mkdir(d, { recursive: true })))\n await Promise.all(\n Object.entries(result.files).map(([path, content]) => writeFile(join(dir, path), content, 'utf8')),\n )\n}\n\nexport type {\n EmitInput,\n EmitResult,\n EmitContent,\n EmitPost,\n QueryPage,\n EmitCssFile,\n EmitOptions,\n} from './types.js'\nexport { wrapLegacyCss } from './css.js'\nexport { pascalCase, patternToPagePath, stableJson } from './util.js'\n"],"mappings":";;;AACA,SAAgB,WAAW,IAAoB;AAC7C,QAAO,GACJ,MAAM,gBAAgB,CACtB,OAAO,QAAQ,CACf,KAAK,SAAS,KAAK,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AAC,KAAK,MAAM,MAAM,GAAG,EAAE,WAAW,MAAM,CAAC,CAAC,CAAC;AACtE,OAAM,QAAQ,IACZ,OAAO,QAAQ,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,aAAa,UAAU,KAAK,KAAK,KAAK,EAAE,SAAS,OAAO,CAAC,CACnG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentrain/emitter-astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Open Astro emitter for Contentrain migrations — renders a ProjectIR into a working Astro project",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@contentrain/types": "1.
|
|
40
|
+
"@contentrain/types": "1.7.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^22.10.0",
|