@sigx/ssg 0.1.6
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/LICENSE +21 -0
- package/README.md +358 -0
- package/dist/build.d.ts +17 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +309 -0
- package/dist/build.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +62 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +28 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +38 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/dev.d.ts +43 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +71 -0
- package/dist/dev.js.map +1 -0
- package/dist/errors.d.ts +58 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/index.d.ts +7 -0
- package/dist/layouts/index.d.ts.map +1 -0
- package/dist/layouts/resolver.d.ts +49 -0
- package/dist/layouts/resolver.d.ts.map +1 -0
- package/dist/layouts/virtual.d.ts +34 -0
- package/dist/layouts/virtual.d.ts.map +1 -0
- package/dist/mdx/frontmatter.d.ts +42 -0
- package/dist/mdx/frontmatter.d.ts.map +1 -0
- package/dist/mdx/index.d.ts +9 -0
- package/dist/mdx/index.d.ts.map +1 -0
- package/dist/mdx/plugin.d.ts +32 -0
- package/dist/mdx/plugin.d.ts.map +1 -0
- package/dist/mdx/rehype-headings.d.ts +39 -0
- package/dist/mdx/rehype-headings.d.ts.map +1 -0
- package/dist/mdx/shiki.d.ts +32 -0
- package/dist/mdx/shiki.d.ts.map +1 -0
- package/dist/plugin-DxH1VUGC.js +547 -0
- package/dist/plugin-DxH1VUGC.js.map +1 -0
- package/dist/routing/index.d.ts +12 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/navigation.d.ts +44 -0
- package/dist/routing/navigation.d.ts.map +1 -0
- package/dist/routing/resolver.d.ts +66 -0
- package/dist/routing/resolver.d.ts.map +1 -0
- package/dist/routing/scanner.d.ts +60 -0
- package/dist/routing/scanner.d.ts.map +1 -0
- package/dist/routing/virtual-navigation.d.ts +39 -0
- package/dist/routing/virtual-navigation.d.ts.map +1 -0
- package/dist/routing/virtual.d.ts +28 -0
- package/dist/routing/virtual.d.ts.map +1 -0
- package/dist/sitemap.d.ts +55 -0
- package/dist/sitemap.d.ts.map +1 -0
- package/dist/types.d.ts +562 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/virtual-entries-Bz97SKQ0.js +1053 -0
- package/dist/virtual-entries-Bz97SKQ0.js.map +1 -0
- package/dist/vite/index.d.ts +6 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +35 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +3 -0
- package/dist/vite/virtual-entries.d.ts +59 -0
- package/dist/vite/virtual-entries.d.ts.map +1 -0
- package/package.json +92 -0
package/dist/dev.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { k as loadConfig } from "./virtual-entries-Bz97SKQ0.js";
|
|
2
|
+
import { n as ssgPlugin } from "./plugin-DxH1VUGC.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
async function dev(options = {}) {
|
|
6
|
+
const root = process.cwd();
|
|
7
|
+
console.log("\nš @sigx/ssg - Starting development server...\n");
|
|
8
|
+
await loadConfig(options.configPath);
|
|
9
|
+
const hasViteConfig = fs.existsSync(path.join(root, "vite.config.ts")) || fs.existsSync(path.join(root, "vite.config.js")) || fs.existsSync(path.join(root, "vite.config.mjs"));
|
|
10
|
+
const vite = await import("vite");
|
|
11
|
+
if (hasViteConfig) {
|
|
12
|
+
console.log("š¦ Using existing vite.config\n");
|
|
13
|
+
const server = await vite.createServer({
|
|
14
|
+
root,
|
|
15
|
+
server: {
|
|
16
|
+
port: options.port,
|
|
17
|
+
host: options.host,
|
|
18
|
+
open: options.open
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
await server.listen();
|
|
22
|
+
server.printUrls();
|
|
23
|
+
} else {
|
|
24
|
+
console.log("š¦ Zero-config mode enabled\n");
|
|
25
|
+
let sigxPlugin;
|
|
26
|
+
try {
|
|
27
|
+
sigxPlugin = (await import("@sigx/vite")).sigxPlugin;
|
|
28
|
+
} catch {
|
|
29
|
+
console.warn("ā ļø @sigx/vite not found, JSX transform may not work");
|
|
30
|
+
console.warn(" Install with: npm install @sigx/vite\n");
|
|
31
|
+
}
|
|
32
|
+
const plugins = [];
|
|
33
|
+
try {
|
|
34
|
+
const tailwind = await import("@tailwindcss/vite");
|
|
35
|
+
plugins.push(tailwind.default());
|
|
36
|
+
} catch {}
|
|
37
|
+
if (sigxPlugin) plugins.push(sigxPlugin());
|
|
38
|
+
plugins.push(...ssgPlugin({ configPath: options.configPath }));
|
|
39
|
+
const server = await vite.createServer({
|
|
40
|
+
root,
|
|
41
|
+
plugins,
|
|
42
|
+
oxc: { jsx: {
|
|
43
|
+
runtime: "automatic",
|
|
44
|
+
importSource: "sigx"
|
|
45
|
+
} },
|
|
46
|
+
server: {
|
|
47
|
+
port: options.port ?? 5173,
|
|
48
|
+
host: options.host,
|
|
49
|
+
open: options.open
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
await server.listen();
|
|
53
|
+
server.printUrls();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function preview(options = {}) {
|
|
57
|
+
const root = process.cwd();
|
|
58
|
+
console.log("\nš @sigx/ssg - Preview server...\n");
|
|
59
|
+
(await (await import("vite")).preview({
|
|
60
|
+
root,
|
|
61
|
+
preview: {
|
|
62
|
+
port: options.port ?? 4173,
|
|
63
|
+
host: options.host,
|
|
64
|
+
open: options.open
|
|
65
|
+
}
|
|
66
|
+
})).printUrls();
|
|
67
|
+
console.log("\n");
|
|
68
|
+
}
|
|
69
|
+
export { dev, preview };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","names":[],"sources":["../src/dev.ts"],"sourcesContent":["/**\r\n * SSG Dev Server\r\n *\r\n * Starts a Vite development server with SSG plugins pre-configured.\r\n * Provides a unified `ssg dev` command for zero-config development.\r\n */\r\n\r\nimport path from 'node:path';\r\nimport fs from 'node:fs';\r\nimport type { SSGConfig } from './types';\r\nimport { loadConfig } from './config';\r\nimport { ssgPlugin } from './vite/plugin';\r\n\r\n/**\r\n * Dev server options\r\n */\r\nexport interface DevOptions {\r\n /**\r\n * Path to ssg.config.ts\r\n */\r\n configPath?: string;\r\n\r\n /**\r\n * Port to run dev server on\r\n * @default 5173\r\n */\r\n port?: number;\r\n\r\n /**\r\n * Host to bind to\r\n * @default 'localhost'\r\n */\r\n host?: string | boolean;\r\n\r\n /**\r\n * Open browser automatically\r\n * @default false\r\n */\r\n open?: boolean;\r\n\r\n /**\r\n * Enable verbose logging\r\n */\r\n verbose?: boolean;\r\n}\r\n\r\n/**\r\n * Start the SSG development server\r\n */\r\nexport async function dev(options: DevOptions = {}): Promise<void> {\r\n const root = process.cwd();\r\n\r\n console.log('\\nš @sigx/ssg - Starting development server...\\n');\r\n\r\n // Load SSG config\r\n const ssgConfig = await loadConfig(options.configPath);\r\n\r\n // Check if user has a vite.config.ts\r\n const hasViteConfig = fs.existsSync(path.join(root, 'vite.config.ts')) ||\r\n fs.existsSync(path.join(root, 'vite.config.js')) ||\r\n fs.existsSync(path.join(root, 'vite.config.mjs'));\r\n\r\n // Import Vite\r\n const vite = await import('vite');\r\n\r\n if (hasViteConfig) {\r\n // User has their own vite.config - use it directly\r\n // They should have ssgPlugin() configured already\r\n console.log('š¦ Using existing vite.config\\n');\r\n\r\n const server = await vite.createServer({\r\n root,\r\n server: {\r\n port: options.port,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n await server.listen();\r\n server.printUrls();\r\n } else {\r\n // Zero-config mode - configure everything automatically\r\n console.log('š¦ Zero-config mode enabled\\n');\r\n\r\n // Try to import @sigx/vite plugin\r\n let sigxPlugin: ((...args: any[]) => any) | undefined;\r\n try {\r\n const sigxVite = await import('@sigx/vite');\r\n sigxPlugin = sigxVite.sigxPlugin;\r\n } catch {\r\n console.warn('ā ļø @sigx/vite not found, JSX transform may not work');\r\n console.warn(' Install with: npm install @sigx/vite\\n');\r\n }\r\n\r\n // Build plugins array\r\n const plugins: any[] = [];\r\n\r\n // Add Tailwind CSS if available\r\n try {\r\n // @ts-expect-error - Optional dependency\r\n const tailwind = await import('@tailwindcss/vite');\r\n plugins.push(tailwind.default());\r\n } catch {\r\n // Tailwind not installed, skip\r\n }\r\n\r\n // Add SignalX plugin if available\r\n if (sigxPlugin) {\r\n plugins.push(sigxPlugin());\r\n }\r\n\r\n // Add SSG plugin\r\n plugins.push(...ssgPlugin({ configPath: options.configPath }));\r\n\r\n const server = await vite.createServer({\r\n root,\r\n plugins,\r\n // Vite 8 uses oxc instead of esbuild for JSX transforms\r\n oxc: {\r\n jsx: {\r\n runtime: 'automatic',\r\n importSource: 'sigx',\r\n }\r\n },\r\n server: {\r\n port: options.port ?? 5173,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n await server.listen();\r\n server.printUrls();\r\n }\r\n}\r\n\r\n/**\r\n * Preview the production build\r\n */\r\nexport async function preview(options: DevOptions = {}): Promise<void> {\r\n const root = process.cwd();\r\n\r\n console.log('\\nš @sigx/ssg - Preview server...\\n');\r\n\r\n const vite = await import('vite');\r\n\r\n const server = await vite.preview({\r\n root,\r\n preview: {\r\n port: options.port ?? 4173,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n server.printUrls();\r\n console.log('\\n');\r\n}\r\n"],"mappings":";;;;AA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QAAQ,KAAK;AAE1B,SAAQ,IAAI,uCAAuC;AAanD,EATe,OAFF,MAAM,OAAO,SAEA,QAAQ;EAC9B;EACA,SAAS;GACL,MAAM,QAAQ,QAAQ;GACtB,MAAM,QAAQ;GACd,MAAM,QAAQ;GACjB;EACJ,CAAC,EAEK,WAAW;AAClB,SAAQ,IAAI,KAAK"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSG Error Classes and Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides structured error messages with file locations and suggestions
|
|
5
|
+
* for common issues encountered during development and build.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base SSG error with enhanced formatting
|
|
9
|
+
*/
|
|
10
|
+
export declare class SSGError extends Error {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly file?: string;
|
|
13
|
+
readonly line?: number;
|
|
14
|
+
readonly suggestion?: string;
|
|
15
|
+
constructor(message: string, options: {
|
|
16
|
+
code: string;
|
|
17
|
+
file?: string;
|
|
18
|
+
line?: number;
|
|
19
|
+
suggestion?: string;
|
|
20
|
+
cause?: Error;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Format error for console output with colors
|
|
24
|
+
*/
|
|
25
|
+
format(root?: string): string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Error codes for categorization
|
|
29
|
+
*/
|
|
30
|
+
export declare const ErrorCodes: {
|
|
31
|
+
readonly CONFIG_NOT_FOUND: "SSG001";
|
|
32
|
+
readonly CONFIG_INVALID: "SSG002";
|
|
33
|
+
readonly CONFIG_THEME_NOT_FOUND: "SSG003";
|
|
34
|
+
readonly PAGE_NOT_FOUND: "SSG100";
|
|
35
|
+
readonly PAGE_INVALID_EXPORT: "SSG101";
|
|
36
|
+
readonly DYNAMIC_ROUTE_NO_PATHS: "SSG102";
|
|
37
|
+
readonly LAYOUT_NOT_FOUND: "SSG103";
|
|
38
|
+
readonly BUILD_RENDER_FAILED: "SSG300";
|
|
39
|
+
readonly BUILD_VITE_FAILED: "SSG301";
|
|
40
|
+
readonly MDX_PARSE_ERROR: "SSG400";
|
|
41
|
+
readonly MDX_FRONTMATTER_ERROR: "SSG401";
|
|
42
|
+
};
|
|
43
|
+
export declare function configNotFoundError(searchedPaths: string[]): SSGError;
|
|
44
|
+
export declare function themeNotFoundError(themeName: string): SSGError;
|
|
45
|
+
export declare function layoutNotFoundError(layoutName: string, pagePath: string, availableLayouts: string[]): SSGError;
|
|
46
|
+
export declare function dynamicRouteNoPaths(filePath: string, routePath: string): SSGError;
|
|
47
|
+
export declare function pageInvalidExport(filePath: string): SSGError;
|
|
48
|
+
export declare function buildRenderError(path: string, error: Error): SSGError;
|
|
49
|
+
export declare function mdxParseError(file: string, error: Error, line?: number): SSGError;
|
|
50
|
+
/**
|
|
51
|
+
* Format and log an SSG error with full context
|
|
52
|
+
*/
|
|
53
|
+
export declare function handleError(error: unknown, root?: string): never;
|
|
54
|
+
/**
|
|
55
|
+
* Wrap an async function with error handling
|
|
56
|
+
*/
|
|
57
|
+
export declare function withErrorHandling<T>(fn: () => Promise<T>, root?: string): Promise<T>;
|
|
58
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAGzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;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igx/ssg - Static Site Generator for SignalX
|
|
3
|
+
*
|
|
4
|
+
* Main entry point - exports all public APIs
|
|
5
|
+
*/
|
|
6
|
+
export type { SSGConfig, SSGRoute, SSGContext, SiteConfig, PageMeta, PageModule, LayoutModule, LayoutProps, LayoutSlots, StaticPath, GetStaticPaths, ThemeModule, ThemeConfig, MarkdownConfig, ShikiConfig, BuildOptions, BuildResult, PageBuildResult, CollectionConfig, NavigationConfig, NavSection, NavItem, TOCConfig, TocHeading, } from './types';
|
|
7
|
+
export { defineSSGConfig, defineSSGConfig as defineConfig } from './config';
|
|
8
|
+
export { generateSitemap, generateRobotsTxt, writeSitemap, pagesToSitemapEntries, } from './sitemap';
|
|
9
|
+
export type { SitemapEntry, SitemapOptions } from './sitemap';
|
|
10
|
+
export { build } from './build';
|
|
11
|
+
export { dev, preview } from './dev';
|
|
12
|
+
export type { DevOptions } from './dev';
|
|
13
|
+
export { SSGError, ErrorCodes, handleError } from './errors';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,cAAc,EACd,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EAEf,gBAAgB,EAEhB,gBAAgB,EAChB,UAAU,EACV,OAAO,EAEP,SAAS,EACT,UAAU,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,eAAe,EAAE,eAAe,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC;AAG5E,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,GACxB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG9D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { O as defineSSGConfig } from "./virtual-entries-Bz97SKQ0.js";
|
|
2
|
+
import { build, i as writeSitemap, n as generateSitemap, r as pagesToSitemapEntries, t as generateRobotsTxt } from "./build.js";
|
|
3
|
+
import "./plugin-DxH1VUGC.js";
|
|
4
|
+
import { dev, preview } from "./dev.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
var SSGError = class extends Error {
|
|
7
|
+
code;
|
|
8
|
+
file;
|
|
9
|
+
line;
|
|
10
|
+
suggestion;
|
|
11
|
+
constructor(message, options) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "SSGError";
|
|
14
|
+
this.code = options.code;
|
|
15
|
+
this.file = options.file;
|
|
16
|
+
this.line = options.line;
|
|
17
|
+
this.suggestion = options.suggestion;
|
|
18
|
+
this.cause = options.cause;
|
|
19
|
+
}
|
|
20
|
+
format(root) {
|
|
21
|
+
const lines = [];
|
|
22
|
+
lines.push(`\nā ${this.code}: ${this.message}\n`);
|
|
23
|
+
if (this.file) {
|
|
24
|
+
const displayPath = root ? path.relative(root, this.file) : this.file;
|
|
25
|
+
if (this.line) lines.push(` š ${displayPath}:${this.line}`);
|
|
26
|
+
else lines.push(` š ${displayPath}`);
|
|
27
|
+
}
|
|
28
|
+
if (this.suggestion) lines.push(`\n š” ${this.suggestion}`);
|
|
29
|
+
lines.push("");
|
|
30
|
+
return lines.join("\n");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const ErrorCodes = {
|
|
34
|
+
CONFIG_NOT_FOUND: "SSG001",
|
|
35
|
+
CONFIG_INVALID: "SSG002",
|
|
36
|
+
CONFIG_THEME_NOT_FOUND: "SSG003",
|
|
37
|
+
PAGE_NOT_FOUND: "SSG100",
|
|
38
|
+
PAGE_INVALID_EXPORT: "SSG101",
|
|
39
|
+
DYNAMIC_ROUTE_NO_PATHS: "SSG102",
|
|
40
|
+
LAYOUT_NOT_FOUND: "SSG103",
|
|
41
|
+
BUILD_RENDER_FAILED: "SSG300",
|
|
42
|
+
BUILD_VITE_FAILED: "SSG301",
|
|
43
|
+
MDX_PARSE_ERROR: "SSG400",
|
|
44
|
+
MDX_FRONTMATTER_ERROR: "SSG401"
|
|
45
|
+
};
|
|
46
|
+
function handleError(error, root) {
|
|
47
|
+
if (error instanceof SSGError) {
|
|
48
|
+
console.error(error.format(root));
|
|
49
|
+
if (error.cause) console.error(" Caused by:", error.cause);
|
|
50
|
+
} else if (error instanceof Error) {
|
|
51
|
+
console.error(`\nā ${error.name}: ${error.message}\n`);
|
|
52
|
+
if (error.stack) console.error(error.stack);
|
|
53
|
+
} else console.error("\nā Unknown error:", error);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
export { ErrorCodes, SSGError, build, defineSSGConfig as defineConfig, defineSSGConfig, dev, generateRobotsTxt, generateSitemap, handleError, pagesToSitemapEntries, preview, writeSitemap };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\r\n * SSG Error Classes and Utilities\r\n *\r\n * Provides structured error messages with file locations and suggestions\r\n * for common issues encountered during development and build.\r\n */\r\n\r\nimport path from 'node:path';\r\n\r\n/**\r\n * Base SSG error with enhanced formatting\r\n */\r\nexport class SSGError extends Error {\r\n readonly code: string;\r\n readonly file?: string;\r\n readonly line?: number;\r\n readonly suggestion?: string;\r\n\r\n constructor(\r\n message: string,\r\n options: {\r\n code: string;\r\n file?: string;\r\n line?: number;\r\n suggestion?: string;\r\n cause?: Error;\r\n }\r\n ) {\r\n super(message);\r\n this.name = 'SSGError';\r\n this.code = options.code;\r\n this.file = options.file;\r\n this.line = options.line;\r\n this.suggestion = options.suggestion;\r\n this.cause = options.cause;\r\n }\r\n\r\n /**\r\n * Format error for console output with colors\r\n */\r\n format(root?: string): string {\r\n const lines: string[] = [];\r\n \r\n // Header with error code\r\n lines.push(`\\nā ${this.code}: ${this.message}\\n`);\r\n \r\n // File location\r\n if (this.file) {\r\n const displayPath = root ? path.relative(root, this.file) : this.file;\r\n if (this.line) {\r\n lines.push(` š ${displayPath}:${this.line}`);\r\n } else {\r\n lines.push(` š ${displayPath}`);\r\n }\r\n }\r\n \r\n // Suggestion\r\n if (this.suggestion) {\r\n lines.push(`\\n š” ${this.suggestion}`);\r\n }\r\n \r\n lines.push('');\r\n return lines.join('\\n');\r\n }\r\n}\r\n\r\n/**\r\n * Error codes for categorization\r\n */\r\nexport const ErrorCodes = {\r\n // Config errors\r\n CONFIG_NOT_FOUND: 'SSG001',\r\n CONFIG_INVALID: 'SSG002',\r\n CONFIG_THEME_NOT_FOUND: 'SSG003',\r\n \r\n // Route/Page errors\r\n PAGE_NOT_FOUND: 'SSG100',\r\n PAGE_INVALID_EXPORT: 'SSG101',\r\n DYNAMIC_ROUTE_NO_PATHS: 'SSG102',\r\n LAYOUT_NOT_FOUND: 'SSG103',\r\n \r\n // Build errors\r\n BUILD_RENDER_FAILED: 'SSG300',\r\n BUILD_VITE_FAILED: 'SSG301',\r\n \r\n // MDX errors\r\n MDX_PARSE_ERROR: 'SSG400',\r\n MDX_FRONTMATTER_ERROR: 'SSG401',\r\n} as const;\r\n\r\n// ============================================================================\r\n// Config Errors\r\n// ============================================================================\r\n\r\nexport function configNotFoundError(searchedPaths: string[]): SSGError {\r\n return new SSGError(\r\n 'No SSG configuration file found',\r\n {\r\n code: ErrorCodes.CONFIG_NOT_FOUND,\r\n suggestion: `Create ssg.config.ts in your project root:\\n\\n` +\r\n ` import { defineSSGConfig } from '@sigx/ssg';\\n` +\r\n ` export default defineSSGConfig({ site: { title: 'My Site' } });`,\r\n }\r\n );\r\n}\r\n\r\nexport function themeNotFoundError(themeName: string): SSGError {\r\n return new SSGError(\r\n `Theme package \"${themeName}\" not found`,\r\n {\r\n code: ErrorCodes.CONFIG_THEME_NOT_FOUND,\r\n suggestion: `Install the theme package:\\n\\n npm install ${themeName}`,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Route/Page Errors\r\n// ============================================================================\r\n\r\nexport function layoutNotFoundError(layoutName: string, pagePath: string, availableLayouts: string[]): SSGError {\r\n const available = availableLayouts.length > 0\r\n ? `Available layouts: ${availableLayouts.join(', ')}`\r\n : 'No layouts found. Create one in src/layouts/';\r\n \r\n return new SSGError(\r\n `Layout \"${layoutName}\" not found`,\r\n {\r\n code: ErrorCodes.LAYOUT_NOT_FOUND,\r\n file: pagePath,\r\n suggestion: `${available}\\n\\n To use a layout, set it in frontmatter:\\n ---\\n layout: default\\n ---`,\r\n }\r\n );\r\n}\r\n\r\nexport function dynamicRouteNoPaths(filePath: string, routePath: string): SSGError {\r\n return new SSGError(\r\n `Dynamic route has no getStaticPaths export`,\r\n {\r\n code: ErrorCodes.DYNAMIC_ROUTE_NO_PATHS,\r\n file: filePath,\r\n suggestion: `Dynamic routes like \"${routePath}\" require a getStaticPaths export:\\n\\n` +\r\n ` export async function getStaticPaths() {\\n` +\r\n ` return [{ params: { slug: 'example' } }];\\n` +\r\n ` }`,\r\n }\r\n );\r\n}\r\n\r\nexport function pageInvalidExport(filePath: string): SSGError {\r\n return new SSGError(\r\n `Page file has no default export`,\r\n {\r\n code: ErrorCodes.PAGE_INVALID_EXPORT,\r\n file: filePath,\r\n suggestion: `Pages must export a default component:\\n\\n` +\r\n ` export default component(() => {\\n` +\r\n ` return () => <div>Page content</div>;\\n` +\r\n ` });`,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Build Errors\r\n// ============================================================================\r\n\r\nexport function buildRenderError(path: string, error: Error): SSGError {\r\n return new SSGError(\r\n `Failed to render page: ${path}`,\r\n {\r\n code: ErrorCodes.BUILD_RENDER_FAILED,\r\n suggestion: `Check the error details below. Common causes:\\n` +\r\n ` - Runtime error in component code\\n` +\r\n ` - Missing dependencies during SSR\\n` +\r\n ` - Browser APIs used during server render`,\r\n cause: error,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// MDX Errors\r\n// ============================================================================\r\n\r\nexport function mdxParseError(file: string, error: Error, line?: number): SSGError {\r\n return new SSGError(\r\n `Failed to parse MDX file`,\r\n {\r\n code: ErrorCodes.MDX_PARSE_ERROR,\r\n file,\r\n line,\r\n suggestion: `Check the MDX syntax. Common issues:\\n` +\r\n ` - Unclosed JSX tags\\n` +\r\n ` - Invalid JavaScript expressions\\n` +\r\n ` - Mixing HTML with JSX incorrectly`,\r\n cause: error,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Error Handler\r\n// ============================================================================\r\n\r\n/**\r\n * Format and log an SSG error with full context\r\n */\r\nexport function handleError(error: unknown, root?: string): never {\r\n if (error instanceof SSGError) {\r\n console.error(error.format(root));\r\n if (error.cause) {\r\n console.error(' Caused by:', error.cause);\r\n }\r\n } else if (error instanceof Error) {\r\n console.error(`\\nā ${error.name}: ${error.message}\\n`);\r\n if (error.stack) {\r\n console.error(error.stack);\r\n }\r\n } else {\r\n console.error('\\nā Unknown error:', error);\r\n }\r\n \r\n process.exit(1);\r\n}\r\n\r\n/**\r\n * Wrap an async function with error handling\r\n */\r\nexport function withErrorHandling<T>(\r\n fn: () => Promise<T>,\r\n root?: string\r\n): Promise<T> {\r\n return fn().catch((error) => {\r\n handleError(error, root);\r\n });\r\n}\r\n"],"mappings":";;;;;AAYA,IAAa,WAAb,cAA8B,MAAM;CAChC;CACA;CACA;CACA;CAEA,YACI,SACA,SAOF;AACE,QAAM,QAAQ;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, getDefaultLayout, findLayout } from './resolver';
|
|
5
|
+
export type { LayoutInfo } from './resolver';
|
|
6
|
+
export { generateLayoutsModule, generateThemeLayoutsModule, loadLayoutsModule, VIRTUAL_LAYOUTS_ID, RESOLVED_VIRTUAL_LAYOUTS_ID } from './virtual';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layouts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/G,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolves layouts from local layouts directory or theme packages.
|
|
5
|
+
* Layouts wrap page content and provide consistent structure.
|
|
6
|
+
*/
|
|
7
|
+
import type { SSGConfig } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Discovered layout information
|
|
10
|
+
*/
|
|
11
|
+
export interface LayoutInfo {
|
|
12
|
+
/**
|
|
13
|
+
* Layout name (e.g., 'default', 'docs', 'blog')
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* Absolute file path to the layout component
|
|
18
|
+
*/
|
|
19
|
+
file: string;
|
|
20
|
+
/**
|
|
21
|
+
* Source: 'local' or theme package name
|
|
22
|
+
*/
|
|
23
|
+
source: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Scan local layouts directory
|
|
27
|
+
*/
|
|
28
|
+
export declare function scanLocalLayouts(config: SSGConfig, root: string): Promise<LayoutInfo[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Load layouts from a theme package
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadThemeLayouts(themeName: string, root: string): Promise<LayoutInfo[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Discover all available layouts
|
|
35
|
+
*
|
|
36
|
+
* Priority order:
|
|
37
|
+
* 1. Local layouts (can override theme)
|
|
38
|
+
* 2. Theme layouts
|
|
39
|
+
*/
|
|
40
|
+
export declare function discoverLayouts(config: SSGConfig, root: string): Promise<LayoutInfo[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the default layout
|
|
43
|
+
*/
|
|
44
|
+
export declare function getDefaultLayout(layouts: LayoutInfo[], config: SSGConfig): LayoutInfo | null;
|
|
45
|
+
/**
|
|
46
|
+
* Find a layout by name
|
|
47
|
+
*/
|
|
48
|
+
export declare function findLayout(layouts: LayoutInfo[], name: string): LayoutInfo | null;
|
|
49
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/layouts/resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,SAAS,EAA6B,MAAM,UAAU,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAClB;AAOD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAwB7F;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAmC7F;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAkB5F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI,CAG5F;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAEjF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual module generator for layouts
|
|
3
|
+
*
|
|
4
|
+
* Generates the virtual:generated-layouts module that provides
|
|
5
|
+
* layout components and the setupLayouts function.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: Layouts are designed to persist across navigation.
|
|
8
|
+
* Instead of wrapping each route with a layout component (which causes
|
|
9
|
+
* full re-renders on navigation), we use a shared LayoutRouter component
|
|
10
|
+
* that maintains the layout and only updates the page content reactively.
|
|
11
|
+
*/
|
|
12
|
+
import type { SSGConfig } from '../types';
|
|
13
|
+
import type { LayoutInfo } from './resolver';
|
|
14
|
+
/**
|
|
15
|
+
* Virtual module ID for generated layouts
|
|
16
|
+
*/
|
|
17
|
+
export declare const VIRTUAL_LAYOUTS_ID = "virtual:generated-layouts";
|
|
18
|
+
export declare const RESOLVED_VIRTUAL_LAYOUTS_ID = "\0virtual:generated-layouts";
|
|
19
|
+
/**
|
|
20
|
+
* Generate the virtual layouts module code
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateLayoutsModule(layouts: LayoutInfo[], config: SSGConfig): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a simpler layouts module for theme-only setups
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateThemeLayoutsModule(themeName: string, config: SSGConfig): string;
|
|
27
|
+
/**
|
|
28
|
+
* Load and generate the layouts module
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadLayoutsModule(config: SSGConfig, root: string): Promise<{
|
|
31
|
+
layouts: LayoutInfo[];
|
|
32
|
+
code: string;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=virtual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["../../src/layouts/virtual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C;;GAEG;AACH,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAC9D,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AASzE;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAwRtF;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAgKvF;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAKlD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frontmatter parser
|
|
3
|
+
*
|
|
4
|
+
* Extracts and parses YAML frontmatter from Markdown/MDX files.
|
|
5
|
+
*/
|
|
6
|
+
import type { PageMeta } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Result of parsing frontmatter
|
|
9
|
+
*/
|
|
10
|
+
export interface FrontmatterResult {
|
|
11
|
+
/**
|
|
12
|
+
* Parsed frontmatter data
|
|
13
|
+
*/
|
|
14
|
+
data: PageMeta;
|
|
15
|
+
/**
|
|
16
|
+
* Content body without frontmatter
|
|
17
|
+
*/
|
|
18
|
+
content: string;
|
|
19
|
+
/**
|
|
20
|
+
* Raw frontmatter string
|
|
21
|
+
*/
|
|
22
|
+
raw: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether frontmatter was present
|
|
25
|
+
*/
|
|
26
|
+
hasFrontmatter: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse frontmatter from content
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseFrontmatter(source: string): FrontmatterResult;
|
|
32
|
+
/**
|
|
33
|
+
* Extract title from markdown content if not in frontmatter
|
|
34
|
+
*
|
|
35
|
+
* Looks for the first H1 heading
|
|
36
|
+
*/
|
|
37
|
+
export declare function extractTitleFromContent(content: string): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Serialize frontmatter back to YAML string
|
|
40
|
+
*/
|
|
41
|
+
export declare function serializeFrontmatter(data: PageMeta): string;
|
|
42
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/mdx/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CASlE;AAyCD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGtE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAsB3D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MDX module exports
|
|
3
|
+
*/
|
|
4
|
+
export { parseFrontmatter, extractTitleFromContent, serializeFrontmatter } from './frontmatter';
|
|
5
|
+
export type { FrontmatterResult } from './frontmatter';
|
|
6
|
+
export { getHighlighter, highlightCode, rehypeShiki, loadLanguage } from './shiki';
|
|
7
|
+
export { mdxPlugin, markdownPlugin } from './plugin';
|
|
8
|
+
export type { MDXPluginOptions } from './plugin';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdx/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChG,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MDX Vite plugin
|
|
3
|
+
*
|
|
4
|
+
* Transforms MDX files into SignalX components with:
|
|
5
|
+
* - Frontmatter extraction
|
|
6
|
+
* - Shiki syntax highlighting
|
|
7
|
+
* - SignalX JSX runtime integration
|
|
8
|
+
*/
|
|
9
|
+
import type { Plugin } from 'vite';
|
|
10
|
+
import type { SSGConfig, MarkdownConfig } from '../types';
|
|
11
|
+
/**
|
|
12
|
+
* MDX plugin options
|
|
13
|
+
*/
|
|
14
|
+
export interface MDXPluginOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Markdown configuration
|
|
17
|
+
*/
|
|
18
|
+
markdown?: MarkdownConfig;
|
|
19
|
+
/**
|
|
20
|
+
* SSG configuration (for layout resolution)
|
|
21
|
+
*/
|
|
22
|
+
ssgConfig?: SSGConfig;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create the MDX Vite plugin
|
|
26
|
+
*/
|
|
27
|
+
export declare function mdxPlugin(options?: MDXPluginOptions): Plugin;
|
|
28
|
+
/**
|
|
29
|
+
* Create a simple markdown-only plugin (no MDX features)
|
|
30
|
+
*/
|
|
31
|
+
export declare function markdownPlugin(options?: MDXPluginOptions): Plugin;
|
|
32
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/mdx/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAwB,MAAM,UAAU,CAAC;AAKhF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAqIhE;AA+GD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAmDrE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rehype plugin to extract headings from MDX/MD content
|
|
3
|
+
*
|
|
4
|
+
* Extracts headings (h2-h6 by default) with their IDs and text content
|
|
5
|
+
* for use in table of contents generation.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Options for the rehype headings plugin
|
|
9
|
+
*/
|
|
10
|
+
export interface RehypeHeadingsOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Minimum heading level to include (1-6)
|
|
13
|
+
* @default 2
|
|
14
|
+
*/
|
|
15
|
+
minLevel?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum heading level to include (1-6)
|
|
18
|
+
* @default 3
|
|
19
|
+
*/
|
|
20
|
+
maxLevel?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Rehype plugin to extract headings from the document
|
|
24
|
+
*
|
|
25
|
+
* Stores extracted headings in `file.data.headings` for later use.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { rehypeExtractHeadings } from './rehype-headings';
|
|
30
|
+
*
|
|
31
|
+
* // Use with unified
|
|
32
|
+
* unified()
|
|
33
|
+
* .use(rehypeSlug) // First add IDs to headings
|
|
34
|
+
* .use(rehypeExtractHeadings, { minLevel: 2, maxLevel: 3 })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function rehypeExtractHeadings(options?: RehypeHeadingsOptions): (tree: any, file: any) => void;
|
|
38
|
+
export default rehypeExtractHeadings;
|
|
39
|
+
//# sourceMappingURL=rehype-headings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rehype-headings.d.ts","sourceRoot":"","sources":["../../src/mdx/rehype-headings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,qBAA0B,IAG7D,MAAM,GAAG,EAAE,MAAM,GAAG,UA4B/B;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shiki syntax highlighting integration
|
|
3
|
+
*
|
|
4
|
+
* Provides code block highlighting for Markdown/MDX content.
|
|
5
|
+
*/
|
|
6
|
+
import { type Highlighter } from 'shiki';
|
|
7
|
+
import type { ShikiConfig } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Initialize or get the Shiki highlighter
|
|
10
|
+
*/
|
|
11
|
+
export declare function getHighlighter(config?: ShikiConfig): Promise<Highlighter>;
|
|
12
|
+
/**
|
|
13
|
+
* Tab types for preview blocks
|
|
14
|
+
*/
|
|
15
|
+
export type TabType = 'preview' | 'code' | 'console';
|
|
16
|
+
/**
|
|
17
|
+
* Highlight code with Shiki
|
|
18
|
+
*/
|
|
19
|
+
export declare function highlightCode(code: string, lang: string, config?: ShikiConfig, meta?: {
|
|
20
|
+
filename?: string;
|
|
21
|
+
live?: boolean;
|
|
22
|
+
tabs?: TabType[];
|
|
23
|
+
}): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Create a rehype plugin for Shiki
|
|
26
|
+
*/
|
|
27
|
+
export declare function rehypeShiki(config?: ShikiConfig): (tree: any) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Load additional language on demand
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadLanguage(lang: string): Promise<void>;
|
|
32
|
+
//# sourceMappingURL=shiki.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shiki.d.ts","sourceRoot":"","sources":["../../src/mdx/shiki.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAqB,KAAK,WAAW,EAA2C,MAAM,OAAO,CAAC;AACrG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAgB5C;;GAEG;AACH,wBAAsB,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAW/E;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAErD;;GAEG;AACH,wBAAsB,aAAa,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,WAAW,EACpB,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,GAC/D,OAAO,CAAC,MAAM,CAAC,CA6GjB;AAsDD;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,IAC9B,MAAM,GAAG,mBA+E1B;AA8BD;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW9D"}
|