@pagesmith/core 0.3.0 → 0.4.1
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 +28 -4
- package/REFERENCE.md +163 -94
- package/dist/ai/index.d.mts +5 -3
- package/dist/ai/index.d.mts.map +1 -1
- package/dist/ai/index.mjs +300 -206
- package/dist/ai/index.mjs.map +1 -1
- package/dist/assets/index.d.mts +10 -1
- package/dist/assets/index.d.mts.map +1 -1
- package/dist/assets/index.mjs +2 -2
- package/dist/{assets-DXiWF_KI.mjs → assets-CAPOqQ_P.mjs} +42 -5
- package/dist/assets-CAPOqQ_P.mjs.map +1 -0
- package/dist/{content-config-Bfe4W9us.d.mts → content-config-Bu2HH0Yx.d.mts} +49 -17
- package/dist/{content-config-Bfe4W9us.d.mts.map → content-config-Bu2HH0Yx.d.mts.map} +1 -1
- package/dist/{content-layer-DPK1EmfY.mjs → content-layer-CJRrNpZ_.mjs} +192 -36
- package/dist/content-layer-CJRrNpZ_.mjs.map +1 -0
- package/dist/content-layer-Ckt08g2i.d.mts +122 -0
- package/dist/content-layer-Ckt08g2i.d.mts.map +1 -0
- package/dist/create/index.d.mts.map +1 -1
- package/dist/create/index.mjs +31 -30
- package/dist/create/index.mjs.map +1 -1
- package/dist/css/index.d.mts +1 -1
- package/dist/css/index.mjs +1 -1
- package/dist/css-CO3CBqxx.mjs +24 -0
- package/dist/css-CO3CBqxx.mjs.map +1 -0
- package/dist/heading-D4X2L4vd.d.mts +12 -0
- package/dist/heading-D4X2L4vd.d.mts.map +1 -0
- package/dist/{index-BBYkDxwI.d.mts → index-B4YZRIzb.d.mts} +1 -1
- package/dist/{index-BBYkDxwI.d.mts.map → index-B4YZRIzb.d.mts.map} +1 -1
- package/dist/{index-Bg9srb5U.d.mts → index-B7NRZAxd.d.mts} +1 -1
- package/dist/{index-Bg9srb5U.d.mts.map → index-B7NRZAxd.d.mts.map} +1 -1
- package/dist/{index-YXQxMV6J.d.mts → index-CryArLlX.d.mts} +2 -2
- package/dist/{index-YXQxMV6J.d.mts.map → index-CryArLlX.d.mts.map} +1 -1
- package/dist/{index-CbOKbkjJ.d.mts → index-D44syBt-.d.mts} +3 -2
- package/dist/index-D44syBt-.d.mts.map +1 -0
- package/dist/index.d.mts +16 -99
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +15 -11
- package/dist/index.mjs.map +1 -1
- package/dist/loaders/index.d.mts +2 -2
- package/dist/loaders/index.mjs +1 -1
- package/dist/{loaders-Cf-BXf2L.mjs → loaders-DnyWfANR.mjs} +3 -3
- package/dist/loaders-DnyWfANR.mjs.map +1 -0
- package/dist/markdown/index.d.mts +2 -2
- package/dist/markdown/index.mjs +1 -1
- package/dist/{markdown-CyrHoDhP.mjs → markdown-DMHd400a.mjs} +29 -2
- package/dist/markdown-DMHd400a.mjs.map +1 -0
- package/dist/{heading-BpDXnl-7.d.mts → markdown-config-CDvh5aJ-.d.mts} +2 -10
- package/dist/markdown-config-CDvh5aJ-.d.mts.map +1 -0
- package/dist/mcp/index.d.mts +23 -0
- package/dist/mcp/index.d.mts.map +1 -0
- package/dist/mcp/index.mjs +2 -0
- package/dist/mcp/server.d.mts +13 -0
- package/dist/mcp/server.d.mts.map +1 -0
- package/dist/mcp/server.mjs +2 -0
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +4 -9
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/schemas/index.d.mts +4 -3
- package/dist/server-BZA_iSen.mjs +203 -0
- package/dist/server-BZA_iSen.mjs.map +1 -0
- package/dist/ssg-utils/index.d.mts +51 -0
- package/dist/ssg-utils/index.d.mts.map +1 -0
- package/dist/ssg-utils/index.mjs +119 -0
- package/dist/ssg-utils/index.mjs.map +1 -0
- package/dist/{types-Cn52sdoq.d.mts → types-B-V5qemH.d.mts} +1 -1
- package/dist/{types-Cn52sdoq.d.mts.map → types-B-V5qemH.d.mts.map} +1 -1
- package/dist/vite/index.d.mts +69 -34
- package/dist/vite/index.d.mts.map +1 -1
- package/dist/vite/index.mjs +296 -228
- package/dist/vite/index.mjs.map +1 -1
- package/docs/agents/AGENTS.md.template +29 -0
- package/docs/agents/changelog-notes.md +15 -0
- package/docs/agents/errors.md +150 -0
- package/docs/agents/migration.md +25 -0
- package/docs/agents/recipes.md +50 -0
- package/docs/agents/usage.md +119 -0
- package/docs/llms-full.txt +111 -0
- package/docs/llms.txt +68 -0
- package/package.json +57 -4
- package/dist/assets-DXiWF_KI.mjs.map +0 -1
- package/dist/content-layer-DPK1EmfY.mjs.map +0 -1
- package/dist/css-BneO430t.mjs +0 -20
- package/dist/css-BneO430t.mjs.map +0 -1
- package/dist/heading-BpDXnl-7.d.mts.map +0 -1
- package/dist/index-CbOKbkjJ.d.mts.map +0 -1
- package/dist/loaders-Cf-BXf2L.mjs.map +0 -1
- package/dist/markdown-CyrHoDhP.mjs.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { d as ValidatorContext, i as CollectionDef, l as ContentValidator, m as ValidationResult, o as InferCollectionData, p as ValidationIssue, t as ContentLayerConfig } from "./content-config-Bu2HH0Yx.mjs";
|
|
2
|
+
import { t as MarkdownConfig } from "./markdown-config-CDvh5aJ-.mjs";
|
|
3
|
+
import { t as Heading } from "./heading-D4X2L4vd.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/convert.d.ts
|
|
6
|
+
type ConvertOptions = {
|
|
7
|
+
markdown?: MarkdownConfig;
|
|
8
|
+
};
|
|
9
|
+
type ConvertResult = {
|
|
10
|
+
html: string;
|
|
11
|
+
toc: Heading[];
|
|
12
|
+
frontmatter: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
declare function convert(input: string, options?: ConvertOptions): Promise<ConvertResult>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/entry.d.ts
|
|
17
|
+
type RenderedContent = {
|
|
18
|
+
/** Processed HTML */html: string; /** Extracted headings for TOC */
|
|
19
|
+
headings: Heading[]; /** Estimated read time in minutes */
|
|
20
|
+
readTime: number;
|
|
21
|
+
};
|
|
22
|
+
declare class ContentEntry<T = Record<string, any>> {
|
|
23
|
+
/** URL-friendly identifier */
|
|
24
|
+
readonly slug: string;
|
|
25
|
+
/** Collection this entry belongs to */
|
|
26
|
+
readonly collection: string;
|
|
27
|
+
/** Absolute path to source file */
|
|
28
|
+
readonly filePath: string;
|
|
29
|
+
/** Validated data (frontmatter or parsed data) */
|
|
30
|
+
readonly data: T;
|
|
31
|
+
/** Raw body content (markdown only) */
|
|
32
|
+
readonly rawContent?: string;
|
|
33
|
+
/** Cached render result */
|
|
34
|
+
private _rendered?;
|
|
35
|
+
/** Markdown config for rendering */
|
|
36
|
+
private _markdownConfig;
|
|
37
|
+
constructor(slug: string, collection: string, filePath: string, data: T, rawContent: string | undefined, markdownConfig: MarkdownConfig);
|
|
38
|
+
/** Render the entry content to HTML. Cached after first call. */
|
|
39
|
+
render(options?: {
|
|
40
|
+
force?: boolean;
|
|
41
|
+
}): Promise<RenderedContent>;
|
|
42
|
+
/** Clear cached render result. */
|
|
43
|
+
clearRenderCache(): void;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/validation/code-block-validator.d.ts
|
|
47
|
+
declare const codeBlockValidator: ContentValidator;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/validation/heading-validator.d.ts
|
|
50
|
+
declare const headingValidator: ContentValidator;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/validation/link-validator.d.ts
|
|
53
|
+
type LinkValidatorOptions = {
|
|
54
|
+
/** Glob patterns for internal links to skip file-existence checks on. */skipPatterns?: string[];
|
|
55
|
+
};
|
|
56
|
+
declare function createLinkValidator(options?: LinkValidatorOptions): ContentValidator;
|
|
57
|
+
declare const linkValidator: ContentValidator;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/validation/runner.d.ts
|
|
60
|
+
/** The built-in validators for markdown content. */
|
|
61
|
+
declare const builtinMarkdownValidators: ContentValidator[];
|
|
62
|
+
/** Run all validators on a single content entry. */
|
|
63
|
+
declare function runValidators(ctx: ValidatorContext, validators: ContentValidator[]): Promise<ValidationIssue[]>;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/content-layer.d.ts
|
|
66
|
+
type WatchEvent = {
|
|
67
|
+
collection: string;
|
|
68
|
+
event: string;
|
|
69
|
+
filename: string | null;
|
|
70
|
+
};
|
|
71
|
+
type WatchHandle = {
|
|
72
|
+
close(): void;
|
|
73
|
+
};
|
|
74
|
+
type WatchCallback = (event: WatchEvent) => void;
|
|
75
|
+
/** Typed content layer that preserves collection schema types. */
|
|
76
|
+
type TypedContentLayer<T extends Record<string, CollectionDef>> = ContentLayer & {
|
|
77
|
+
getCollection<K extends keyof T & string>(name: K): Promise<ContentEntry<InferCollectionData<T[K]>>[]>;
|
|
78
|
+
getEntry<K extends keyof T & string>(collection: K, slug: string): Promise<ContentEntry<InferCollectionData<T[K]>> | undefined>;
|
|
79
|
+
};
|
|
80
|
+
interface ContentLayer {
|
|
81
|
+
/** Get all entries in a collection. */
|
|
82
|
+
getCollection(name: string): Promise<ContentEntry[]>;
|
|
83
|
+
/** Get a single entry by collection name and slug. */
|
|
84
|
+
getEntry(collection: string, slug: string): Promise<ContentEntry | undefined>;
|
|
85
|
+
/** Convert raw markdown to HTML (no collection, no validation). */
|
|
86
|
+
convert(markdown: string, options?: LayerConvertOptions): Promise<ConvertResult>;
|
|
87
|
+
/** Invalidate a single entry's cache. */
|
|
88
|
+
invalidate(collection: string, slug: string): Promise<void>;
|
|
89
|
+
/** Invalidate an entire collection's cache. */
|
|
90
|
+
invalidateCollection(collection: string): Promise<void>;
|
|
91
|
+
/** Invalidate all cached data. */
|
|
92
|
+
invalidateAll(): void;
|
|
93
|
+
/** Validate all entries in a collection (or all collections). */
|
|
94
|
+
validate(collection?: string): Promise<ValidationResult[]>;
|
|
95
|
+
/** Get the names of all configured collections. */
|
|
96
|
+
getCollectionNames(): string[];
|
|
97
|
+
/** Get the definition of a collection. */
|
|
98
|
+
getCollectionDef(name: string): CollectionDef | undefined;
|
|
99
|
+
/** Get all collection definitions. */
|
|
100
|
+
getCollections(): Record<string, CollectionDef>;
|
|
101
|
+
/** Invalidate entries in a collection that match a predicate. Returns count of invalidated entries. */
|
|
102
|
+
invalidateWhere(collection: string, predicate: (entry: ContentEntry) => boolean): Promise<number>;
|
|
103
|
+
/** Watch collection directories for changes. Returns a handle to stop watching. */
|
|
104
|
+
watch(callback: WatchCallback): WatchHandle;
|
|
105
|
+
/** Get cache statistics for debugging and monitoring. */
|
|
106
|
+
getCacheStats(): {
|
|
107
|
+
collections: number;
|
|
108
|
+
entries: Record<string, number>;
|
|
109
|
+
totalEntries: number;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
type LayerConvertOptions = {
|
|
113
|
+
markdown?: MarkdownConfig;
|
|
114
|
+
};
|
|
115
|
+
/** Create a new content layer from a configuration. */
|
|
116
|
+
declare function createContentLayer<T extends Record<string, CollectionDef>>(config: ContentLayerConfig & {
|
|
117
|
+
collections: T;
|
|
118
|
+
}): TypedContentLayer<T>;
|
|
119
|
+
declare function createContentLayer(config: ContentLayerConfig): ContentLayer;
|
|
120
|
+
//#endregion
|
|
121
|
+
export { ConvertResult as _, WatchEvent as a, builtinMarkdownValidators as c, linkValidator as d, headingValidator as f, ConvertOptions as g, RenderedContent as h, WatchCallback as i, runValidators as l, ContentEntry as m, LayerConvertOptions as n, WatchHandle as o, codeBlockValidator as p, TypedContentLayer as r, createContentLayer as s, ContentLayer as t, createLinkValidator as u, convert as v };
|
|
122
|
+
//# sourceMappingURL=content-layer-Ckt08g2i.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-layer-Ckt08g2i.d.mts","names":[],"sources":["../src/convert.ts","../src/entry.ts","../src/validation/code-block-validator.ts","../src/validation/heading-validator.ts","../src/validation/link-validator.ts","../src/validation/runner.ts","../src/content-layer.ts"],"mappings":";;;;;KAIY,cAAA;EACV,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AA,GAAqB,YAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/create/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/create/index.ts"],"mappings":";;AAiCA;;;;KAAY,QAAA;EACV,IAAA;EACA,WAAA;EACA,MAAA;EACA,IAAA;EACA,UAAA;EACA,OAAA,EAAS,MAAA;AAAA;AAAA,cAGE,SAAA,EAAW,QAAA;AAAA,iBAkFR,aAAA,CAAA;AAAA,iBAmJM,aAAA,CAAc,WAAA,UAAqB,YAAA,WAAuB,OAAA"}
|
package/dist/create/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { join, resolve } from "path";
|
|
2
1
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, unlinkSync, writeFileSync } from "fs";
|
|
2
|
+
import { join, resolve } from "path";
|
|
3
3
|
import { tmpdir } from "os";
|
|
4
|
-
import { execSync } from "child_process";
|
|
4
|
+
import { execFileSync, execSync } from "child_process";
|
|
5
5
|
//#region src/create/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* Project scaffolding for `pagesmith create`.
|
|
@@ -9,7 +9,14 @@ import { execSync } from "child_process";
|
|
|
9
9
|
* Supports local templates (bundled) and remote templates (GitHub examples).
|
|
10
10
|
*/
|
|
11
11
|
const GITHUB_REPO = "sujeet-pro/pagesmith";
|
|
12
|
-
|
|
12
|
+
function getPackageVersion() {
|
|
13
|
+
try {
|
|
14
|
+
const pkgPath = resolve(import.meta.dirname, "..", "..", "package.json");
|
|
15
|
+
return `^${JSON.parse(readFileSync(pkgPath, "utf-8")).version ?? "0.1.0"}`;
|
|
16
|
+
} catch {
|
|
17
|
+
return "^0.1.0";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
13
20
|
const templates = [
|
|
14
21
|
{
|
|
15
22
|
name: "docs",
|
|
@@ -30,8 +37,9 @@ const templates = [
|
|
|
30
37
|
path: "examples/blog-site",
|
|
31
38
|
dependency: "@pagesmith/core",
|
|
32
39
|
scripts: {
|
|
33
|
-
dev: "
|
|
34
|
-
build: "
|
|
40
|
+
dev: "vp dev",
|
|
41
|
+
build: "vp build",
|
|
42
|
+
check: "vp check"
|
|
35
43
|
}
|
|
36
44
|
},
|
|
37
45
|
{
|
|
@@ -42,7 +50,8 @@ const templates = [
|
|
|
42
50
|
dependency: "@pagesmith/core",
|
|
43
51
|
scripts: {
|
|
44
52
|
dev: "vp dev",
|
|
45
|
-
build: "
|
|
53
|
+
build: "vp build",
|
|
54
|
+
check: "vp check",
|
|
46
55
|
preview: "vp preview"
|
|
47
56
|
}
|
|
48
57
|
},
|
|
@@ -54,7 +63,8 @@ const templates = [
|
|
|
54
63
|
dependency: "@pagesmith/core",
|
|
55
64
|
scripts: {
|
|
56
65
|
dev: "vp dev",
|
|
57
|
-
build: "
|
|
66
|
+
build: "vp build",
|
|
67
|
+
check: "vp check",
|
|
58
68
|
preview: "vp preview"
|
|
59
69
|
}
|
|
60
70
|
},
|
|
@@ -66,7 +76,8 @@ const templates = [
|
|
|
66
76
|
dependency: "@pagesmith/core",
|
|
67
77
|
scripts: {
|
|
68
78
|
dev: "vp dev",
|
|
69
|
-
build: "
|
|
79
|
+
build: "vp build",
|
|
80
|
+
check: "vp check",
|
|
70
81
|
preview: "vp preview"
|
|
71
82
|
}
|
|
72
83
|
},
|
|
@@ -77,8 +88,9 @@ const templates = [
|
|
|
77
88
|
path: "examples/with-vanilla-ejs",
|
|
78
89
|
dependency: "@pagesmith/core",
|
|
79
90
|
scripts: {
|
|
80
|
-
dev: "
|
|
81
|
-
build: "
|
|
91
|
+
dev: "vp dev",
|
|
92
|
+
build: "vp build",
|
|
93
|
+
check: "vp check"
|
|
82
94
|
}
|
|
83
95
|
},
|
|
84
96
|
{
|
|
@@ -88,8 +100,9 @@ const templates = [
|
|
|
88
100
|
path: "examples/with-vanilla-hbs",
|
|
89
101
|
dependency: "@pagesmith/core",
|
|
90
102
|
scripts: {
|
|
91
|
-
dev: "
|
|
92
|
-
build: "
|
|
103
|
+
dev: "vp dev",
|
|
104
|
+
build: "vp build",
|
|
105
|
+
check: "vp check"
|
|
93
106
|
}
|
|
94
107
|
}
|
|
95
108
|
];
|
|
@@ -113,21 +126,6 @@ async function downloadFromGithub(templatePath, destination) {
|
|
|
113
126
|
if (!existsSync(sourcePath)) throw new Error(`Template path not found in repo: ${templatePath}`);
|
|
114
127
|
mkdirSync(destination, { recursive: true });
|
|
115
128
|
cpSync(sourcePath, destination, { recursive: true });
|
|
116
|
-
const sharedContentPath = join(tmpExtract, topDir, "examples/shared-content");
|
|
117
|
-
if (existsSync(sharedContentPath) && templatePath.startsWith("examples/with-")) {
|
|
118
|
-
const contentDest = join(destination, "content");
|
|
119
|
-
mkdirSync(contentDest, { recursive: true });
|
|
120
|
-
for (const subDir of [
|
|
121
|
-
"posts",
|
|
122
|
-
"pages",
|
|
123
|
-
"authors"
|
|
124
|
-
]) {
|
|
125
|
-
const srcDir = join(sharedContentPath, subDir);
|
|
126
|
-
if (existsSync(srcDir)) cpSync(srcDir, join(contentDest, subDir), { recursive: true });
|
|
127
|
-
}
|
|
128
|
-
const configSrc = join(sharedContentPath, "content.config.mjs");
|
|
129
|
-
if (existsSync(configSrc)) cpSync(configSrc, join(destination, "content.config.mjs"));
|
|
130
|
-
}
|
|
131
129
|
} finally {
|
|
132
130
|
unlinkSync(tmpFile);
|
|
133
131
|
rmSync(tmpExtract, {
|
|
@@ -179,12 +177,15 @@ function writePackageJson(destination, projectName, template) {
|
|
|
179
177
|
pkg.version = "0.0.0";
|
|
180
178
|
pkg.scripts = template.scripts;
|
|
181
179
|
if (pkg.dependencies) {
|
|
182
|
-
for (const [name, version] of Object.entries(pkg.dependencies)) if (version === "*" && name.startsWith("@pagesmith/")) pkg.dependencies[name] =
|
|
180
|
+
for (const [name, version] of Object.entries(pkg.dependencies)) if (version === "*" && name.startsWith("@pagesmith/")) pkg.dependencies[name] = getPackageVersion();
|
|
183
181
|
}
|
|
184
182
|
pkg.dependencies = pkg.dependencies ?? {};
|
|
185
|
-
pkg.dependencies[template.dependency] =
|
|
183
|
+
pkg.dependencies[template.dependency] = getPackageVersion();
|
|
186
184
|
if (pkg.devDependencies?.vite && !pkg.devDependencies["vite-plus"]) pkg.devDependencies["vite-plus"] = "^0.1.13";
|
|
187
|
-
|
|
185
|
+
try {
|
|
186
|
+
const npmVersion = execFileSync("npm", ["--version"], { encoding: "utf-8" }).trim();
|
|
187
|
+
pkg.packageManager = `npm@${npmVersion}`;
|
|
188
|
+
} catch {}
|
|
188
189
|
writeFileSync(existingPkg, JSON.stringify(pkg, null, 2) + "\n");
|
|
189
190
|
}
|
|
190
191
|
async function createProject(projectName, templateName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/create/index.ts"],"sourcesContent":["/**\n * Project scaffolding for `pagesmith create`.\n *\n * Supports local templates (bundled) and remote templates (GitHub examples).\n */\n\nimport {\n cpSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readdirSync,\n readFileSync,\n rmSync,\n unlinkSync,\n writeFileSync,\n} from 'fs'\nimport { join, resolve } from 'path'\nimport { execSync } from 'child_process'\nimport { tmpdir } from 'os'\n\nconst GITHUB_REPO = 'sujeet-pro/pagesmith'\nconst PACKAGE_VERSION = '^0.1.0'\n\nexport type Template = {\n name: string\n description: string\n source: 'local' | 'github'\n path: string\n dependency: '@pagesmith/core' | '@pagesmith/docs'\n scripts: Record<string, string>\n}\n\nexport const templates: Template[] = [\n {\n name: 'docs',\n description: 'Documentation site with @pagesmith/docs',\n source: 'local',\n path: 'templates/docs',\n dependency: '@pagesmith/docs',\n scripts: { dev: 'pagesmith dev', build: 'pagesmith build', preview: 'pagesmith preview' },\n },\n {\n name: 'blog',\n description: 'Blog with custom layouts using @pagesmith/core',\n source: 'github',\n path: 'examples/blog-site',\n dependency: '@pagesmith/core',\n scripts: { dev: 'node --watch build.mjs', build: 'node build.mjs' },\n },\n {\n name: 'react',\n description: 'React SSG site with react-router',\n source: 'github',\n path: 'examples/with-react',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'vp dev',\n build: 'node build.mjs',\n preview: 'vp preview',\n },\n },\n {\n name: 'solid',\n description: 'SolidJS SSG site',\n source: 'github',\n path: 'examples/with-solid',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'vp dev',\n build: 'node build.mjs',\n preview: 'vp preview',\n },\n },\n {\n name: 'svelte',\n description: 'Svelte SSG site',\n source: 'github',\n path: 'examples/with-svelte',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'vp dev',\n build: 'node build.mjs',\n preview: 'vp preview',\n },\n },\n {\n name: 'ejs',\n description: 'Vanilla Node.js + EJS templates',\n source: 'github',\n path: 'examples/with-vanilla-ejs',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'node --watch build.mjs',\n build: 'node build.mjs',\n },\n },\n {\n name: 'hbs',\n description: 'Vanilla Node.js + Handlebars templates',\n source: 'github',\n path: 'examples/with-vanilla-hbs',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'node --watch build.mjs',\n build: 'node build.mjs',\n },\n },\n]\n\nexport function listTemplates(): string {\n const maxName = Math.max(...templates.map((t) => t.name.length))\n return templates.map((t) => ` ${t.name.padEnd(maxName + 2)} ${t.description}`).join('\\n')\n}\n\nasync function downloadFromGithub(templatePath: string, destination: string): Promise<void> {\n const tarballUrl = `https://github.com/${GITHUB_REPO}/archive/refs/heads/main.tar.gz`\n console.log('Downloading template from GitHub...')\n\n const response = await fetch(tarballUrl, { redirect: 'follow' })\n if (!response.ok) {\n throw new Error(`Failed to download: ${response.status} ${response.statusText}`)\n }\n\n const tmpFile = join(tmpdir(), `pagesmith-${Date.now()}.tar.gz`)\n const tmpExtract = mkdtempSync(join(tmpdir(), 'pagesmith-'))\n\n try {\n writeFileSync(tmpFile, Buffer.from(await response.arrayBuffer()))\n\n // Extract full tarball\n execSync(`tar xzf ${tmpFile} -C ${tmpExtract}`, { stdio: 'pipe' })\n\n // Find the extracted top-level directory\n const dirs = readdirSync(tmpExtract)\n const topDir = dirs[0]\n if (!topDir) throw new Error('Empty tarball')\n\n const sourcePath = join(tmpExtract, topDir, templatePath)\n if (!existsSync(sourcePath)) {\n throw new Error(`Template path not found in repo: ${templatePath}`)\n }\n\n mkdirSync(destination, { recursive: true })\n cpSync(sourcePath, destination, { recursive: true })\n\n // Also copy shared-content for framework examples\n const sharedContentPath = join(tmpExtract, topDir, 'examples/shared-content')\n if (existsSync(sharedContentPath) && templatePath.startsWith('examples/with-')) {\n const contentDest = join(destination, 'content')\n mkdirSync(contentDest, { recursive: true })\n\n // Copy markdown/data files from shared-content\n for (const subDir of ['posts', 'pages', 'authors']) {\n const srcDir = join(sharedContentPath, subDir)\n if (existsSync(srcDir)) {\n cpSync(srcDir, join(contentDest, subDir), { recursive: true })\n }\n }\n\n // Copy content config\n const configSrc = join(sharedContentPath, 'content.config.mjs')\n if (existsSync(configSrc)) {\n cpSync(configSrc, join(destination, 'content.config.mjs'))\n }\n }\n } finally {\n unlinkSync(tmpFile)\n rmSync(tmpExtract, { recursive: true, force: true })\n }\n}\n\nfunction adaptForStandalone(destination: string, template: Template): void {\n // Update content.config.mjs paths (from ./posts to ./content/posts)\n const configPath = join(destination, 'content.config.mjs')\n if (existsSync(configPath)) {\n let config = readFileSync(configPath, 'utf-8')\n config = config.replace(/directory: '\\.\\/posts'/g, \"directory: './content/posts'\")\n config = config.replace(/directory: '\\.\\/pages'/g, \"directory: './content/pages'\")\n config = config.replace(/directory: '\\.\\/authors'/g, \"directory: './content/authors'\")\n config = config.replace(/directory: '\\.\\/config'/g, \"directory: './content/config'\")\n writeFileSync(configPath, config)\n }\n\n // Update vite.config.ts shared-content references\n const viteConfigPath = join(destination, 'vite.config.ts')\n if (existsSync(viteConfigPath)) {\n let config = readFileSync(viteConfigPath, 'utf-8')\n config = config.replace(\n /import content from '\\.\\.\\/shared-content\\/content\\.config'/g,\n \"import content from './content.config.mjs'\",\n )\n config = config.replace(\n /configPath:\\s*'\\.\\.\\/shared-content\\/content\\.config\\.ts'/g,\n \"configPath: './content.config.mjs'\",\n )\n config = config.replace(\n /root:\\s*resolve\\(import\\.meta\\.dirname,\\s*'\\.\\.\\/shared-content'\\)/g,\n 'root: import.meta.dirname',\n )\n writeFileSync(viteConfigPath, config)\n }\n\n // Update build.mjs (remove shared-content references)\n const buildPath = join(destination, 'build.mjs')\n if (existsSync(buildPath)) {\n let script = readFileSync(buildPath, 'utf-8')\n // Replace shared-content imports\n script = script.replace(\n /import .* from '\\.\\.\\/shared-content\\/content\\.config\\.mjs'/g,\n \"import content from './content.config.mjs'\",\n )\n // Simplify content layer setup\n script = script.replace(\n /const contentRoot = resolve\\(root, '\\.\\.\\/shared-content'\\)/g,\n 'const contentRoot = root',\n )\n // Fix named imports\n script = script.replace(\n /import \\{ pages, posts \\} from '\\.\\.\\/shared-content\\/content\\.config\\.mjs'/g,\n \"import content from './content.config.mjs'\\nconst { pages, posts } = content\",\n )\n writeFileSync(buildPath, script)\n }\n\n // Remove workspace-specific tsconfig paths\n const tsconfigPath = join(destination, 'tsconfig.json')\n if (existsSync(tsconfigPath)) {\n const tsconfig = JSON.parse(readFileSync(tsconfigPath, 'utf-8'))\n if (tsconfig.compilerOptions?.paths) {\n delete tsconfig.compilerOptions.paths\n }\n writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + '\\n')\n }\n}\n\nfunction writePackageJson(destination: string, projectName: string, template: Template): void {\n const existingPkg = join(destination, 'package.json')\n let pkg: Record<string, any> = {}\n\n if (existsSync(existingPkg)) {\n pkg = JSON.parse(readFileSync(existingPkg, 'utf-8'))\n }\n\n pkg.name = projectName\n pkg.private = true\n pkg.type = 'module'\n pkg.version = '0.0.0'\n pkg.scripts = template.scripts\n\n // Replace workspace \"*\" deps with actual versions\n if (pkg.dependencies) {\n for (const [name, version] of Object.entries(pkg.dependencies)) {\n if (version === '*' && name.startsWith('@pagesmith/')) {\n pkg.dependencies[name] = PACKAGE_VERSION\n }\n }\n }\n\n // Ensure the primary dependency is present\n pkg.dependencies = pkg.dependencies ?? {}\n pkg.dependencies[template.dependency] = PACKAGE_VERSION\n\n // Keep Vite+ in standalone examples that already use it\n if (pkg.devDependencies?.vite && !pkg.devDependencies['vite-plus']) {\n pkg.devDependencies['vite-plus'] = '^0.1.13'\n }\n\n pkg.packageManager = 'npm@11.12.0'\n\n writeFileSync(existingPkg, JSON.stringify(pkg, null, 2) + '\\n')\n}\n\nexport async function createProject(projectName: string, templateName: string): Promise<void> {\n const template = templates.find((t) => t.name === templateName)\n if (!template) {\n throw new Error(`Unknown template \"${templateName}\". Available templates:\\n${listTemplates()}`)\n }\n\n const destination = resolve(projectName)\n if (existsSync(destination) && readdirSync(destination).length > 0) {\n throw new Error(`Directory \"${projectName}\" already exists and is not empty.`)\n }\n\n if (template.source === 'local') {\n const templateDir = resolve(\n import.meta.dirname,\n '../../templates',\n template.path.split('/').pop()!,\n )\n mkdirSync(destination, { recursive: true })\n cpSync(templateDir, destination, { recursive: true })\n } else {\n await downloadFromGithub(template.path, destination)\n adaptForStandalone(destination, template)\n }\n\n writePackageJson(destination, projectName, template)\n\n console.log(`\\nCreated \"${projectName}\" from the \"${template.name}\" template.\\n`)\n console.log('Next steps:')\n console.log(` cd ${projectName}`)\n console.log(' vp install')\n if (template.scripts.dev) {\n console.log(` vp run dev`)\n } else {\n console.log(` vp run build`)\n }\n console.log()\n}\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,cAAc;AACpB,MAAM,kBAAkB;AAWxB,MAAa,YAAwB;CACnC;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GAAE,KAAK;GAAiB,OAAO;GAAmB,SAAS;GAAqB;EAC1F;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GAAE,KAAK;GAA0B,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AAc;AAGxC,KAAI,IAAI,iBAAiB,QAAQ,CAAC,IAAI,gBAAgB,aACpD,KAAI,gBAAgB,eAAe;AAGrC,KAAI,iBAAiB;AAErB,eAAc,aAAa,KAAK,UAAU,KAAK,MAAM,EAAE,GAAG,KAAK;;AAGjE,eAAsB,cAAc,aAAqB,cAAqC;CAC5F,MAAM,WAAW,UAAU,MAAM,MAAM,EAAE,SAAS,aAAa;AAC/D,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qBAAqB,aAAa,2BAA2B,eAAe,GAAG;CAGjG,MAAM,cAAc,QAAQ,YAAY;AACxC,KAAI,WAAW,YAAY,IAAI,YAAY,YAAY,CAAC,SAAS,EAC/D,OAAM,IAAI,MAAM,cAAc,YAAY,oCAAoC;AAGhF,KAAI,SAAS,WAAW,SAAS;EAC/B,MAAM,cAAc,QAClB,OAAO,KAAK,SACZ,mBACA,SAAS,KAAK,MAAM,IAAI,CAAC,KAAK,CAC/B;AACD,YAAU,aAAa,EAAE,WAAW,MAAM,CAAC;AAC3C,SAAO,aAAa,aAAa,EAAE,WAAW,MAAM,CAAC;QAChD;AACL,QAAM,mBAAmB,SAAS,MAAM,YAAY;AACpD,qBAAmB,aAAa,SAAS;;AAG3C,kBAAiB,aAAa,aAAa,SAAS;AAEpD,SAAQ,IAAI,cAAc,YAAY,cAAc,SAAS,KAAK,eAAe;AACjF,SAAQ,IAAI,cAAc;AAC1B,SAAQ,IAAI,QAAQ,cAAc;AAClC,SAAQ,IAAI,eAAe;AAC3B,KAAI,SAAS,QAAQ,IACnB,SAAQ,IAAI,eAAe;KAE3B,SAAQ,IAAI,iBAAiB;AAE/B,SAAQ,KAAK"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/create/index.ts"],"sourcesContent":["/**\n * Project scaffolding for `pagesmith create`.\n *\n * Supports local templates (bundled) and remote templates (GitHub examples).\n */\n\nimport {\n cpSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readdirSync,\n readFileSync,\n rmSync,\n unlinkSync,\n writeFileSync,\n} from 'fs'\nimport { join, resolve } from 'path'\nimport { execFileSync, execSync } from 'child_process'\nimport { tmpdir } from 'os'\n\nconst GITHUB_REPO = 'sujeet-pro/pagesmith'\n\nfunction getPackageVersion(): string {\n try {\n const pkgPath = resolve(import.meta.dirname, '..', '..', 'package.json')\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8')) as { version?: string }\n return `^${pkg.version ?? '0.1.0'}`\n } catch {\n return '^0.1.0'\n }\n}\n\nexport type Template = {\n name: string\n description: string\n source: 'local' | 'github'\n path: string\n dependency: '@pagesmith/core' | '@pagesmith/docs'\n scripts: Record<string, string>\n}\n\nexport const templates: Template[] = [\n {\n name: 'docs',\n description: 'Documentation site with @pagesmith/docs',\n source: 'local',\n path: 'templates/docs',\n dependency: '@pagesmith/docs',\n scripts: { dev: 'pagesmith dev', build: 'pagesmith build', preview: 'pagesmith preview' },\n },\n {\n name: 'blog',\n description: 'Blog with custom layouts using @pagesmith/core',\n source: 'github',\n path: 'examples/blog-site',\n dependency: '@pagesmith/core',\n scripts: { dev: 'vp dev', build: 'vp build', check: 'vp check' },\n },\n {\n name: 'react',\n description: 'React SSG site with react-router',\n source: 'github',\n path: 'examples/with-react',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'vp dev',\n build: 'vp build',\n check: 'vp check',\n preview: 'vp preview',\n },\n },\n {\n name: 'solid',\n description: 'SolidJS SSG site',\n source: 'github',\n path: 'examples/with-solid',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'vp dev',\n build: 'vp build',\n check: 'vp check',\n preview: 'vp preview',\n },\n },\n {\n name: 'svelte',\n description: 'Svelte SSG site',\n source: 'github',\n path: 'examples/with-svelte',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'vp dev',\n build: 'vp build',\n check: 'vp check',\n preview: 'vp preview',\n },\n },\n {\n name: 'ejs',\n description: 'Vanilla Node.js + EJS templates',\n source: 'github',\n path: 'examples/with-vanilla-ejs',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'vp dev',\n build: 'vp build',\n check: 'vp check',\n },\n },\n {\n name: 'hbs',\n description: 'Vanilla Node.js + Handlebars templates',\n source: 'github',\n path: 'examples/with-vanilla-hbs',\n dependency: '@pagesmith/core',\n scripts: {\n dev: 'vp dev',\n build: 'vp build',\n check: 'vp check',\n },\n },\n]\n\nexport function listTemplates(): string {\n const maxName = Math.max(...templates.map((t) => t.name.length))\n return templates.map((t) => ` ${t.name.padEnd(maxName + 2)} ${t.description}`).join('\\n')\n}\n\nasync function downloadFromGithub(templatePath: string, destination: string): Promise<void> {\n const tarballUrl = `https://github.com/${GITHUB_REPO}/archive/refs/heads/main.tar.gz`\n console.log('Downloading template from GitHub...')\n\n const response = await fetch(tarballUrl, { redirect: 'follow' })\n if (!response.ok) {\n throw new Error(`Failed to download: ${response.status} ${response.statusText}`)\n }\n\n const tmpFile = join(tmpdir(), `pagesmith-${Date.now()}.tar.gz`)\n const tmpExtract = mkdtempSync(join(tmpdir(), 'pagesmith-'))\n\n try {\n writeFileSync(tmpFile, Buffer.from(await response.arrayBuffer()))\n\n // Extract full tarball\n execSync(`tar xzf ${tmpFile} -C ${tmpExtract}`, { stdio: 'pipe' })\n\n // Find the extracted top-level directory\n const dirs = readdirSync(tmpExtract)\n const topDir = dirs[0]\n if (!topDir) throw new Error('Empty tarball')\n\n const sourcePath = join(tmpExtract, topDir, templatePath)\n if (!existsSync(sourcePath)) {\n throw new Error(`Template path not found in repo: ${templatePath}`)\n }\n\n mkdirSync(destination, { recursive: true })\n cpSync(sourcePath, destination, { recursive: true })\n } finally {\n unlinkSync(tmpFile)\n rmSync(tmpExtract, { recursive: true, force: true })\n }\n}\n\nfunction adaptForStandalone(destination: string, template: Template): void {\n // Update content.config.mjs paths (from ./posts to ./content/posts)\n const configPath = join(destination, 'content.config.mjs')\n if (existsSync(configPath)) {\n let config = readFileSync(configPath, 'utf-8')\n config = config.replace(/directory: '\\.\\/posts'/g, \"directory: './content/posts'\")\n config = config.replace(/directory: '\\.\\/pages'/g, \"directory: './content/pages'\")\n config = config.replace(/directory: '\\.\\/authors'/g, \"directory: './content/authors'\")\n config = config.replace(/directory: '\\.\\/config'/g, \"directory: './content/config'\")\n writeFileSync(configPath, config)\n }\n\n // Update vite.config.ts shared-content references\n const viteConfigPath = join(destination, 'vite.config.ts')\n if (existsSync(viteConfigPath)) {\n let config = readFileSync(viteConfigPath, 'utf-8')\n config = config.replace(\n /import content from '\\.\\.\\/shared-content\\/content\\.config'/g,\n \"import content from './content.config.mjs'\",\n )\n config = config.replace(\n /configPath:\\s*'\\.\\.\\/shared-content\\/content\\.config\\.ts'/g,\n \"configPath: './content.config.mjs'\",\n )\n config = config.replace(\n /root:\\s*resolve\\(import\\.meta\\.dirname,\\s*'\\.\\.\\/shared-content'\\)/g,\n 'root: import.meta.dirname',\n )\n writeFileSync(viteConfigPath, config)\n }\n\n // Update build.mjs (remove shared-content references)\n const buildPath = join(destination, 'build.mjs')\n if (existsSync(buildPath)) {\n let script = readFileSync(buildPath, 'utf-8')\n // Replace shared-content imports\n script = script.replace(\n /import .* from '\\.\\.\\/shared-content\\/content\\.config\\.mjs'/g,\n \"import content from './content.config.mjs'\",\n )\n // Simplify content layer setup\n script = script.replace(\n /const contentRoot = resolve\\(root, '\\.\\.\\/shared-content'\\)/g,\n 'const contentRoot = root',\n )\n // Fix named imports\n script = script.replace(\n /import \\{ pages, posts \\} from '\\.\\.\\/shared-content\\/content\\.config\\.mjs'/g,\n \"import content from './content.config.mjs'\\nconst { pages, posts } = content\",\n )\n writeFileSync(buildPath, script)\n }\n\n // Remove workspace-specific tsconfig paths\n const tsconfigPath = join(destination, 'tsconfig.json')\n if (existsSync(tsconfigPath)) {\n const tsconfig = JSON.parse(readFileSync(tsconfigPath, 'utf-8'))\n if (tsconfig.compilerOptions?.paths) {\n delete tsconfig.compilerOptions.paths\n }\n writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + '\\n')\n }\n}\n\nfunction writePackageJson(destination: string, projectName: string, template: Template): void {\n const existingPkg = join(destination, 'package.json')\n let pkg: Record<string, any> = {}\n\n if (existsSync(existingPkg)) {\n pkg = JSON.parse(readFileSync(existingPkg, 'utf-8'))\n }\n\n pkg.name = projectName\n pkg.private = true\n pkg.type = 'module'\n pkg.version = '0.0.0'\n pkg.scripts = template.scripts\n\n // Replace workspace \"*\" deps with actual versions\n if (pkg.dependencies) {\n for (const [name, version] of Object.entries(pkg.dependencies)) {\n if (version === '*' && name.startsWith('@pagesmith/')) {\n pkg.dependencies[name] = getPackageVersion()\n }\n }\n }\n\n // Ensure the primary dependency is present\n pkg.dependencies = pkg.dependencies ?? {}\n pkg.dependencies[template.dependency] = getPackageVersion()\n\n // Keep Vite+ in standalone examples that already use it\n if (pkg.devDependencies?.vite && !pkg.devDependencies['vite-plus']) {\n pkg.devDependencies['vite-plus'] = '^0.1.13'\n }\n\n try {\n const npmVersion = execFileSync('npm', ['--version'], { encoding: 'utf-8' }).trim()\n pkg.packageManager = `npm@${npmVersion}`\n } catch {\n // Omit packageManager if npm version cannot be detected\n }\n\n writeFileSync(existingPkg, JSON.stringify(pkg, null, 2) + '\\n')\n}\n\nexport async function createProject(projectName: string, templateName: string): Promise<void> {\n const template = templates.find((t) => t.name === templateName)\n if (!template) {\n throw new Error(`Unknown template \"${templateName}\". Available templates:\\n${listTemplates()}`)\n }\n\n const destination = resolve(projectName)\n if (existsSync(destination) && readdirSync(destination).length > 0) {\n throw new Error(`Directory \"${projectName}\" already exists and is not empty.`)\n }\n\n if (template.source === 'local') {\n const templateDir = resolve(\n import.meta.dirname,\n '../../templates',\n template.path.split('/').pop()!,\n )\n mkdirSync(destination, { recursive: true })\n cpSync(templateDir, destination, { recursive: true })\n } else {\n await downloadFromGithub(template.path, destination)\n adaptForStandalone(destination, template)\n }\n\n writePackageJson(destination, projectName, template)\n\n console.log(`\\nCreated \"${projectName}\" from the \"${template.name}\" template.\\n`)\n console.log('Next steps:')\n console.log(` cd ${projectName}`)\n console.log(' vp install')\n if (template.scripts.dev) {\n console.log(` vp run dev`)\n } else {\n console.log(` vp run build`)\n }\n console.log()\n}\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,cAAc;AAEpB,SAAS,oBAA4B;AACnC,KAAI;EACF,MAAM,UAAU,QAAQ,OAAO,KAAK,SAAS,MAAM,MAAM,eAAe;AAExE,SAAO,IADK,KAAK,MAAM,aAAa,SAAS,QAAQ,CAAC,CACvC,WAAW;SACpB;AACN,SAAO;;;AAaX,MAAa,YAAwB;CACnC;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GAAE,KAAK;GAAiB,OAAO;GAAmB,SAAS;GAAqB;EAC1F;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GAAE,KAAK;GAAU,OAAO;GAAY,OAAO;GAAY;EACjE;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GACP,KAAK;GACL,OAAO;GACP,OAAO;GACP,SAAS;GACV;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GACP,KAAK;GACL,OAAO;GACP,OAAO;GACP,SAAS;GACV;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GACP,KAAK;GACL,OAAO;GACP,OAAO;GACP,SAAS;GACV;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GACP,KAAK;GACL,OAAO;GACP,OAAO;GACR;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GACP,KAAK;GACL,OAAO;GACP,OAAO;GACR;EACF;CACF;AAED,SAAgB,gBAAwB;CACtC,MAAM,UAAU,KAAK,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3B,SAAQ,IAAI,iBAAiB;AAE/B,SAAQ,KAAK"}
|
package/dist/css/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as buildCss } from "../index-
|
|
1
|
+
import { n as buildCss } from "../index-B7NRZAxd.mjs";
|
|
2
2
|
export { buildCss };
|
package/dist/css/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as buildCss } from "../css-
|
|
1
|
+
import { t as buildCss } from "../css-CO3CBqxx.mjs";
|
|
2
2
|
export { buildCss };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
import { bundle } from "lightningcss";
|
|
3
|
+
//#region src/css/builder.ts
|
|
4
|
+
function buildCss(entryPath, config) {
|
|
5
|
+
const targets = config?.targets ?? {};
|
|
6
|
+
try {
|
|
7
|
+
const { code } = bundle({
|
|
8
|
+
filename: resolve(entryPath),
|
|
9
|
+
minify: config?.minify ?? true,
|
|
10
|
+
targets: {
|
|
11
|
+
chrome: (targets.chrome ?? 123) << 16,
|
|
12
|
+
firefox: (targets.firefox ?? 120) << 16,
|
|
13
|
+
safari: (targets.safari ?? 18) << 16
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return new TextDecoder().decode(code);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
throw new Error(`CSS build failed for ${entryPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { buildCss as t };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=css-CO3CBqxx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-CO3CBqxx.mjs","names":[],"sources":["../src/css/builder.ts"],"sourcesContent":["import { bundle } from 'lightningcss'\nimport { resolve } from 'path'\n\nexport type CssBuildOptions = {\n minify?: boolean\n targets?: {\n chrome?: number\n firefox?: number\n safari?: number\n }\n}\n\nexport function buildCss(entryPath: string, config?: CssBuildOptions): string {\n const targets = config?.targets ?? {}\n try {\n const { code } = bundle({\n filename: resolve(entryPath),\n minify: config?.minify ?? true,\n targets: {\n chrome: (targets.chrome ?? 123) << 16,\n firefox: (targets.firefox ?? 120) << 16,\n safari: (targets.safari ?? 18) << 16,\n },\n })\n return new TextDecoder().decode(code)\n } catch (err) {\n throw new Error(\n `CSS build failed for ${entryPath}: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err },\n )\n }\n}\n"],"mappings":";;;AAYA,SAAgB,SAAS,WAAmB,QAAkC;CAC5E,MAAM,UAAU,QAAQ,WAAW,EAAE;AACrC,KAAI;EACF,MAAM,EAAE,SAAS,OAAO;GACtB,UAAU,QAAQ,UAAU;GAC5B,QAAQ,QAAQ,UAAU;GAC1B,SAAS;IACP,SAAS,QAAQ,UAAU,QAAQ;IACnC,UAAU,QAAQ,WAAW,QAAQ;IACrC,SAAS,QAAQ,UAAU,OAAO;IACnC;GACF,CAAC;AACF,SAAO,IAAI,aAAa,CAAC,OAAO,KAAK;UAC9B,KAAK;AACZ,QAAM,IAAI,MACR,wBAAwB,UAAU,IAAI,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,IACtF,EAAE,OAAO,KAAK,CACf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/schemas/heading.d.ts
|
|
4
|
+
declare const HeadingSchema: z.ZodObject<{
|
|
5
|
+
depth: z.ZodNumber;
|
|
6
|
+
text: z.ZodString;
|
|
7
|
+
slug: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
type Heading = z.infer<typeof HeadingSchema>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { HeadingSchema as n, Heading as t };
|
|
12
|
+
//# sourceMappingURL=heading-D4X2L4vd.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading-D4X2L4vd.d.mts","names":[],"sources":["../src/schemas/heading.ts"],"mappings":";;;cAIa,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;KAMd,OAAA,GAAU,CAAA,CAAE,KAAA,QAAa,aAAA"}
|
|
@@ -38,4 +38,4 @@ declare const BlogFrontmatterSchema: z.ZodObject<{
|
|
|
38
38
|
type BlogFrontmatter = z.infer<typeof BlogFrontmatterSchema>;
|
|
39
39
|
//#endregion
|
|
40
40
|
export { ProjectFrontmatter as a, BlogFrontmatterSchema as i, BaseFrontmatterSchema as n, ProjectFrontmatterSchema as o, BlogFrontmatter as r, BaseFrontmatter as t };
|
|
41
|
-
//# sourceMappingURL=index-
|
|
41
|
+
//# sourceMappingURL=index-B4YZRIzb.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-B4YZRIzb.d.mts","names":[],"sources":["../src/schemas/frontmatter.ts"],"mappings":";;;cAIa,qBAAA,EAAqB,CAAA,CAAA,SAAA;;;;;;;;KAWtB,eAAA,GAAkB,CAAA,CAAE,KAAA,QAAa,qBAAA;AAAA,cAIhC,wBAAA,EAAwB,CAAA,CAAA,SAAA;;;;;;;;;;;;;KAYzB,kBAAA,GAAqB,CAAA,CAAE,KAAA,QAAa,wBAAA;AAAA,cAInC,qBAAA,EAAqB,CAAA,CAAA,SAAA;;;;;;;;;;;KAMtB,eAAA,GAAkB,CAAA,CAAE,KAAA,QAAa,qBAAA"}
|
|
@@ -10,4 +10,4 @@ type CssBuildOptions = {
|
|
|
10
10
|
declare function buildCss(entryPath: string, config?: CssBuildOptions): string;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { buildCss as n, CssBuildOptions as t };
|
|
13
|
-
//# sourceMappingURL=index-
|
|
13
|
+
//# sourceMappingURL=index-B7NRZAxd.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-B7NRZAxd.d.mts","names":[],"sources":["../src/css/builder.ts"],"mappings":";KAGY,eAAA;EACV,MAAA;EACA,OAAA;IACE,MAAA;IACA,OAAA;IACA,MAAA;EAAA;AAAA;AAAA,iBAIY,QAAA,CAAS,SAAA,UAAmB,MAAA,GAAS,eAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as LoaderResult, r as LoaderType, t as Loader } from "./types-
|
|
1
|
+
import { n as LoaderResult, r as LoaderType, t as Loader } from "./types-B-V5qemH.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/loaders/json.d.ts
|
|
4
4
|
declare class JsonLoader implements Loader {
|
|
@@ -58,4 +58,4 @@ declare function resolveLoader(loaderOrType: LoaderType | Loader): Loader;
|
|
|
58
58
|
declare function defaultIncludePatterns(loader: Loader): string[];
|
|
59
59
|
//#endregion
|
|
60
60
|
export { TomlLoader as a, JsoncLoader as c, YamlLoader as i, JsonLoader as l, registerLoader as n, MarkdownLoader as o, resolveLoader as r, LoaderError as s, defaultIncludePatterns as t };
|
|
61
|
-
//# sourceMappingURL=index-
|
|
61
|
+
//# sourceMappingURL=index-CryArLlX.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-CryArLlX.d.mts","names":[],"sources":["../src/loaders/json.ts","../src/loaders/jsonc.ts","../src/loaders/errors.ts","../src/loaders/markdown.ts","../src/loaders/toml.ts","../src/loaders/yaml.ts","../src/loaders/index.ts"],"mappings":";;;cAWa,UAAA,YAAsB,MAAA;EACjC,IAAA;EACA,IAAA;EACA,UAAA;EAEM,IAAA,CAAK,QAAA,WAAmB,OAAA,CAAQ,YAAA;AAAA;;;cCoC3B,WAAA,YAAuB,MAAA;EAClC,IAAA;EACA,IAAA;EACA,UAAA;EAEM,IAAA,CAAK,QAAA,WAAmB,OAAA,CAAQ,YAAA;AAAA;;;cCzD3B,WAAA,SAAoB,KAAA;EAAA,SACtB,QAAA;EAAA,SACA,MAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;cAEG,OAAA,UAAiB,QAAA,UAAkB,MAAA,UAAgB,IAAA,WAAe,MAAA;AAAA;;;cCOnE,cAAA,YAA0B,MAAA;EACrC,IAAA;EACA,IAAA;EACA,UAAA;EAEM,IAAA,CAAK,QAAA,WAAmB,OAAA,CAAQ,YAAA;AAAA;;;cCT3B,UAAA,YAAsB,MAAA;EACjC,IAAA;EACA,IAAA;EACA,UAAA;EAEM,IAAA,CAAK,QAAA,WAAmB,OAAA,CAAQ,YAAA;AAAA;;;cCL3B,UAAA,YAAsB,MAAA;EACjC,IAAA;EACA,IAAA;EACA,UAAA;EAEM,IAAA,CAAK,QAAA,WAAmB,OAAA,CAAQ,YAAA;AAAA;;;;iBCgBxB,cAAA,CAAe,IAAA,UAAc,MAAA,EAAQ,MAAA;;iBAKrC,aAAA,CAAc,YAAA,EAAc,UAAA,GAAa,MAAA,GAAS,MAAA;;iBAwBlD,sBAAA,CAAuB,MAAA,EAAQ,MAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as MarkdownConfig } from "./markdown-config-CDvh5aJ-.mjs";
|
|
2
|
+
import { t as Heading } from "./heading-D4X2L4vd.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/markdown/pipeline.d.ts
|
|
4
5
|
type MarkdownResult = {
|
|
@@ -12,4 +13,4 @@ declare function processMarkdown(raw: string, config?: MarkdownConfig, preExtrac
|
|
|
12
13
|
}): Promise<MarkdownResult>;
|
|
13
14
|
//#endregion
|
|
14
15
|
export { processMarkdown as n, MarkdownResult as t };
|
|
15
|
-
//# sourceMappingURL=index-
|
|
16
|
+
//# sourceMappingURL=index-D44syBt-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D44syBt-.d.mts","names":[],"sources":["../src/markdown/pipeline.ts"],"mappings":";;;;KAuBY,cAAA;EACV,IAAA;EACA,QAAA,EAAU,OAAA;EACV,WAAA,EAAa,MAAA;AAAA;AAAA,iBA8JO,eAAA,CACpB,GAAA,UACA,MAAA,GAAS,cAAA,EACT,YAAA;EAAiB,OAAA;EAAiB,WAAA,EAAa,MAAA;AAAA,IAC9C,OAAA,CAAQ,cAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { n as buildCss, t as CssBuildOptions } from "./index-B7NRZAxd.mjs";
|
|
2
|
+
import { n as LoaderResult, r as LoaderType, t as Loader } from "./types-B-V5qemH.mjs";
|
|
3
|
+
import { a as CollectionMap, c as RawEntry, d as ValidatorContext, f as ValidationEntryResult, i as CollectionDef, l as ContentValidator, m as ValidationResult, n as ContentPlugin, o as InferCollectionData, p as ValidationIssue, r as CollectionComputed, s as InferCollectionLoaderKind, t as ContentLayerConfig, u as ResolvedValidatorContext } from "./content-config-Bu2HH0Yx.mjs";
|
|
4
|
+
import { n as MarkdownConfigSchema, t as MarkdownConfig } from "./markdown-config-CDvh5aJ-.mjs";
|
|
5
|
+
import { n as HeadingSchema, t as Heading } from "./heading-D4X2L4vd.mjs";
|
|
6
|
+
import { _ as ConvertResult, a as WatchEvent, c as builtinMarkdownValidators, d as linkValidator, f as headingValidator, g as ConvertOptions, h as RenderedContent, i as WatchCallback, l as runValidators, m as ContentEntry, n as LayerConvertOptions, o as WatchHandle, p as codeBlockValidator, r as TypedContentLayer, s as createContentLayer, t as ContentLayer, u as createLinkValidator, v as convert } from "./content-layer-Ckt08g2i.mjs";
|
|
6
7
|
import { Fragment, HtmlString, h } from "./jsx-runtime/index.mjs";
|
|
7
|
-
import { n as processMarkdown, t as MarkdownResult } from "./index-
|
|
8
|
-
import { a as ProjectFrontmatter, i as BlogFrontmatterSchema, n as BaseFrontmatterSchema, o as ProjectFrontmatterSchema, r as BlogFrontmatter, t as BaseFrontmatter } from "./index-
|
|
9
|
-
import { a as TomlLoader, c as JsoncLoader, i as YamlLoader, l as JsonLoader, n as registerLoader, o as MarkdownLoader } from "./index-
|
|
8
|
+
import { n as processMarkdown, t as MarkdownResult } from "./index-D44syBt-.mjs";
|
|
9
|
+
import { a as ProjectFrontmatter, i as BlogFrontmatterSchema, n as BaseFrontmatterSchema, o as ProjectFrontmatterSchema, r as BlogFrontmatter, t as BaseFrontmatter } from "./index-B4YZRIzb.mjs";
|
|
10
|
+
import { a as TomlLoader, c as JsoncLoader, i as YamlLoader, l as JsonLoader, n as registerLoader, o as MarkdownLoader } from "./index-CryArLlX.mjs";
|
|
10
11
|
import { ZodSchema, z, z as z$1 } from "zod";
|
|
11
12
|
|
|
12
13
|
//#region src/config.d.ts
|
|
@@ -19,95 +20,6 @@ declare function defineCollection<const S extends z$1.ZodType, const TComputed e
|
|
|
19
20
|
/** Define a named collection map with strong literal inference. */
|
|
20
21
|
declare function defineCollections<const TCollections extends CollectionMap>(collections: TCollections): TCollections;
|
|
21
22
|
//#endregion
|
|
22
|
-
//#region src/convert.d.ts
|
|
23
|
-
type ConvertOptions = {
|
|
24
|
-
markdown?: MarkdownConfig;
|
|
25
|
-
};
|
|
26
|
-
type ConvertResult = {
|
|
27
|
-
html: string;
|
|
28
|
-
toc: Heading[];
|
|
29
|
-
frontmatter: Record<string, unknown>;
|
|
30
|
-
};
|
|
31
|
-
declare function convert(input: string, options?: ConvertOptions): Promise<ConvertResult>;
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/entry.d.ts
|
|
34
|
-
type RenderedContent = {
|
|
35
|
-
/** Processed HTML */html: string; /** Extracted headings for TOC */
|
|
36
|
-
headings: Heading[]; /** Estimated read time in minutes */
|
|
37
|
-
readTime: number;
|
|
38
|
-
};
|
|
39
|
-
declare class ContentEntry<T = Record<string, any>> {
|
|
40
|
-
/** URL-friendly identifier */
|
|
41
|
-
readonly slug: string;
|
|
42
|
-
/** Collection this entry belongs to */
|
|
43
|
-
readonly collection: string;
|
|
44
|
-
/** Absolute path to source file */
|
|
45
|
-
readonly filePath: string;
|
|
46
|
-
/** Validated data (frontmatter or parsed data) */
|
|
47
|
-
readonly data: T;
|
|
48
|
-
/** Raw body content (markdown only) */
|
|
49
|
-
readonly rawContent?: string;
|
|
50
|
-
/** Cached render result */
|
|
51
|
-
private _rendered?;
|
|
52
|
-
/** Markdown config for rendering */
|
|
53
|
-
private _markdownConfig;
|
|
54
|
-
constructor(slug: string, collection: string, filePath: string, data: T, rawContent: string | undefined, markdownConfig: MarkdownConfig);
|
|
55
|
-
/** Render the entry content to HTML. Cached after first call. */
|
|
56
|
-
render(options?: {
|
|
57
|
-
force?: boolean;
|
|
58
|
-
}): Promise<RenderedContent>;
|
|
59
|
-
/** Clear cached render result. */
|
|
60
|
-
clearRenderCache(): void;
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/validation/code-block-validator.d.ts
|
|
64
|
-
declare const codeBlockValidator: ContentValidator;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/validation/heading-validator.d.ts
|
|
67
|
-
declare const headingValidator: ContentValidator;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/validation/link-validator.d.ts
|
|
70
|
-
type LinkValidatorOptions = {
|
|
71
|
-
/** Glob patterns for internal links to skip file-existence checks on. */skipPatterns?: string[];
|
|
72
|
-
};
|
|
73
|
-
declare function createLinkValidator(options?: LinkValidatorOptions): ContentValidator;
|
|
74
|
-
declare const linkValidator: ContentValidator;
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/validation/runner.d.ts
|
|
77
|
-
/** The built-in validators for markdown content. */
|
|
78
|
-
declare const builtinMarkdownValidators: ContentValidator[];
|
|
79
|
-
/** Run all validators on a single content entry. */
|
|
80
|
-
declare function runValidators(ctx: ValidatorContext, validators: ContentValidator[]): Promise<ValidationIssue[]>;
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/content-layer.d.ts
|
|
83
|
-
interface ContentLayer {
|
|
84
|
-
/** Get all entries in a collection. */
|
|
85
|
-
getCollection(name: string): Promise<ContentEntry[]>;
|
|
86
|
-
/** Get a single entry by collection name and slug. */
|
|
87
|
-
getEntry(collection: string, slug: string): Promise<ContentEntry | undefined>;
|
|
88
|
-
/** Convert raw markdown to HTML (no collection, no validation). */
|
|
89
|
-
convert(markdown: string, options?: LayerConvertOptions): Promise<ConvertResult>;
|
|
90
|
-
/** Invalidate a single entry's cache. */
|
|
91
|
-
invalidate(collection: string, slug: string): Promise<void>;
|
|
92
|
-
/** Invalidate an entire collection's cache. */
|
|
93
|
-
invalidateCollection(collection: string): Promise<void>;
|
|
94
|
-
/** Invalidate all cached data. */
|
|
95
|
-
invalidateAll(): void;
|
|
96
|
-
/** Validate all entries in a collection (or all collections). */
|
|
97
|
-
validate(collection?: string): Promise<ValidationResult[]>;
|
|
98
|
-
/** Get the names of all configured collections. */
|
|
99
|
-
getCollectionNames(): string[];
|
|
100
|
-
/** Get the definition of a collection. */
|
|
101
|
-
getCollectionDef(name: string): CollectionDef | undefined;
|
|
102
|
-
/** Get all collection definitions. */
|
|
103
|
-
getCollections(): Record<string, CollectionDef>;
|
|
104
|
-
}
|
|
105
|
-
type LayerConvertOptions = {
|
|
106
|
-
markdown?: MarkdownConfig;
|
|
107
|
-
};
|
|
108
|
-
/** Create a new content layer from a configuration. */
|
|
109
|
-
declare function createContentLayer(config: ContentLayerConfig): ContentLayer;
|
|
110
|
-
//#endregion
|
|
111
23
|
//#region src/frontmatter.d.ts
|
|
112
24
|
type FrontmatterResult = {
|
|
113
25
|
frontmatter: Record<string, any>;
|
|
@@ -115,7 +27,12 @@ type FrontmatterResult = {
|
|
|
115
27
|
};
|
|
116
28
|
/** Extract frontmatter from raw markdown using gray-matter. */
|
|
117
29
|
declare function extractFrontmatter(raw: string): FrontmatterResult;
|
|
118
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Validate frontmatter against a Zod schema. Returns parsed data or errors.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Use `validateSchema()` from `@pagesmith/core` for richer
|
|
34
|
+
* validation results including field paths and severity levels.
|
|
35
|
+
*/
|
|
119
36
|
declare function validateFrontmatter<T>(frontmatter: Record<string, any>, schema: ZodSchema<T>): {
|
|
120
37
|
success: true;
|
|
121
38
|
data: T;
|
|
@@ -133,5 +50,5 @@ declare function validateFrontmatter<T>(frontmatter: Record<string, any>, schema
|
|
|
133
50
|
*/
|
|
134
51
|
declare function extractToc(html: string): Heading[];
|
|
135
52
|
//#endregion
|
|
136
|
-
export { type
|
|
53
|
+
export { type BaseFrontmatter, BaseFrontmatterSchema, type BlogFrontmatter, BlogFrontmatterSchema, type CollectionComputed, type CollectionDef, type CollectionMap, ContentEntry, type ContentLayer, type ContentLayerConfig, type ContentPlugin, type ContentValidator, type ConvertOptions, type ConvertResult, type CssBuildOptions, Fragment, type FrontmatterResult, type Heading, HeadingSchema, HtmlString, type InferCollectionData, type InferCollectionLoaderKind, JsonLoader, JsoncLoader, type LayerConvertOptions, type Loader, type LoaderResult, type LoaderType, type MarkdownConfig, MarkdownConfigSchema, MarkdownLoader, type MarkdownResult, type ProjectFrontmatter, ProjectFrontmatterSchema, type RawEntry, type RenderedContent, type ResolvedValidatorContext, TomlLoader, type TypedContentLayer, type ValidationEntryResult, type ValidationIssue, type ValidationResult, type ValidatorContext, type WatchCallback, type WatchEvent, type WatchHandle, YamlLoader, buildCss, builtinMarkdownValidators, codeBlockValidator, convert, createContentLayer, createLinkValidator, defineCollection, defineCollections, defineConfig, extractFrontmatter, extractToc, h, headingValidator, linkValidator, processMarkdown, registerLoader, runValidators, validateFrontmatter, z };
|
|
137
54
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/frontmatter.ts","../src/toc.ts"],"mappings":";;;;;;;;;;;;;;iBAagB,YAAA,CAAa,MAAA,EAAQ,kBAAA,GAAqB,kBAAA;;iBAK1C,gBAAA,iBACE,GAAA,CAAE,OAAA,0BACM,kBAAA,6BACF,UAAA,GAAa,MAAA,GAAS,UAAA,GAAa,MAAA,CAAA,CAEzD,GAAA,EAAK,IAAA,CAAK,aAAA,CAAc,CAAA,EAAG,SAAA,EAAW,OAAA;EACpC,QAAA,GAAW,SAAA,GAAY,kBAAA;AAAA,IAExB,aAAA,CAAc,CAAA,EAAG,SAAA,EAAW,OAAA;;iBAKf,iBAAA,4BAA6C,aAAA,CAAA,CAC3D,WAAA,EAAa,YAAA,GACZ,YAAA;;;KCrBS,iBAAA;EACV,WAAA,EAAa,MAAA;EACb,OAAA;AAAA;;iBAIc,kBAAA,CAAmB,GAAA,WAAc,iBAAA;ADLjD;;;;;;AAAA,iBCgBgB,mBAAA,GAAA,CACd,WAAA,EAAa,MAAA,eACb,MAAA,EAAQ,SAAA,CAAU,CAAA;EACf,OAAA;EAAe,IAAA,EAAM,CAAA;AAAA;EAAQ,OAAA;EAAgB,MAAA;AAAA;;;;;;;;;iBCxBlC,UAAA,CAAW,IAAA,WAAe,OAAA"}
|