@pagesmith/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +481 -0
  2. package/assets/fonts/OFL.txt +7 -0
  3. package/assets/fonts/jetbrains-mono-variable.woff2 +0 -0
  4. package/assets/fonts/open-sans-variable.woff2 +0 -0
  5. package/assets/fonts.css +17 -0
  6. package/dist/ai/index.d.mts +41 -0
  7. package/dist/ai/index.d.mts.map +1 -0
  8. package/dist/ai/index.mjs +414 -0
  9. package/dist/ai/index.mjs.map +1 -0
  10. package/dist/assets/index.d.mts +31 -0
  11. package/dist/assets/index.d.mts.map +1 -0
  12. package/dist/assets/index.mjs +2 -0
  13. package/dist/assets-bX08zEJm.mjs +155 -0
  14. package/dist/assets-bX08zEJm.mjs.map +1 -0
  15. package/dist/content-config-fHPaFZ7i.d.mts +1128 -0
  16. package/dist/content-config-fHPaFZ7i.d.mts.map +1 -0
  17. package/dist/content-layer-B7fQ3im4.mjs +590 -0
  18. package/dist/content-layer-B7fQ3im4.mjs.map +1 -0
  19. package/dist/convert-DnuB6SVV.mjs +52 -0
  20. package/dist/convert-DnuB6SVV.mjs.map +1 -0
  21. package/dist/create/index.d.mts +20 -0
  22. package/dist/create/index.d.mts.map +1 -0
  23. package/dist/create/index.mjs +215 -0
  24. package/dist/create/index.mjs.map +1 -0
  25. package/dist/css/index.d.mts +2 -0
  26. package/dist/css/index.mjs +2 -0
  27. package/dist/css-ekIt2Fdb.mjs +19 -0
  28. package/dist/css-ekIt2Fdb.mjs.map +1 -0
  29. package/dist/heading-Dhvzlay-.d.mts +27 -0
  30. package/dist/heading-Dhvzlay-.d.mts.map +1 -0
  31. package/dist/index-BQ6B1-qG.d.mts +41 -0
  32. package/dist/index-BQ6B1-qG.d.mts.map +1 -0
  33. package/dist/index-CeNDTM-y.d.mts +7 -0
  34. package/dist/index-CeNDTM-y.d.mts.map +1 -0
  35. package/dist/index-DpRBzO8Q.d.mts +15 -0
  36. package/dist/index-DpRBzO8Q.d.mts.map +1 -0
  37. package/dist/index-sFCx17CD.d.mts +59 -0
  38. package/dist/index-sFCx17CD.d.mts.map +1 -0
  39. package/dist/index.d.mts +131 -0
  40. package/dist/index.d.mts.map +1 -0
  41. package/dist/index.mjs +56 -0
  42. package/dist/index.mjs.map +1 -0
  43. package/dist/jsx-runtime/index.d.mts +24 -0
  44. package/dist/jsx-runtime/index.d.mts.map +1 -0
  45. package/dist/jsx-runtime/index.mjs +88 -0
  46. package/dist/jsx-runtime/index.mjs.map +1 -0
  47. package/dist/loaders/index.d.mts +3 -0
  48. package/dist/loaders/index.mjs +2 -0
  49. package/dist/loaders-DyABmDrE.mjs +179 -0
  50. package/dist/loaders-DyABmDrE.mjs.map +1 -0
  51. package/dist/markdown/index.d.mts +3 -0
  52. package/dist/markdown/index.mjs +2 -0
  53. package/dist/markdown-Cj5X26FL.mjs +95 -0
  54. package/dist/markdown-Cj5X26FL.mjs.map +1 -0
  55. package/dist/runtime/index.d.mts +28 -0
  56. package/dist/runtime/index.d.mts.map +1 -0
  57. package/dist/runtime/index.mjs +90 -0
  58. package/dist/runtime/index.mjs.map +1 -0
  59. package/dist/schemas/index.d.mts +4 -0
  60. package/dist/schemas/index.mjs +2 -0
  61. package/dist/schemas-DJS7wOzd.mjs +47 -0
  62. package/dist/schemas-DJS7wOzd.mjs.map +1 -0
  63. package/dist/types-DUsjRE7Y.d.mts +28 -0
  64. package/dist/types-DUsjRE7Y.d.mts.map +1 -0
  65. package/dist/vite/index.d.mts +9878 -0
  66. package/dist/vite/index.d.mts.map +1 -0
  67. package/dist/vite/index.mjs +549 -0
  68. package/dist/vite/index.mjs.map +1 -0
  69. package/package.json +136 -0
  70. package/src/styles/code/inline.css +26 -0
  71. package/src/styles/content/alerts.css +87 -0
  72. package/src/styles/content/prose.css +225 -0
  73. package/src/styles/content/toc.css +87 -0
  74. package/src/styles/content.css +22 -0
  75. package/src/styles/foundations/reset.css +49 -0
  76. package/src/styles/foundations/tokens.css +66 -0
  77. package/src/styles/layout/grid.css +179 -0
  78. package/src/styles/layout/sidebar.css +18 -0
  79. package/src/styles/standalone.css +18 -0
  80. package/src/styles/viewport.css +20 -0
  81. package/templates/docs/content/README.md +18 -0
  82. package/templates/docs/content/guide/README.md +11 -0
  83. package/templates/docs/content/guide/getting-started/README.md +9 -0
  84. package/templates/docs/content/reference/README.md +11 -0
  85. package/templates/docs/pagesmith.config.json5 +15 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-layer-B7fQ3im4.mjs","names":[],"sources":["../src/utils/read-time.ts","../src/entry.ts","../src/plugins/index.ts","../src/utils/glob.ts","../src/utils/slug.ts","../src/validation/schema-validator.ts","../src/validation/code-block-validator.ts","../src/validation/heading-validator.ts","../src/validation/link-validator.ts","../src/validation/runner.ts","../src/store.ts","../src/content-layer.ts"],"sourcesContent":["/**\n * Read time estimation.\n *\n * Computes estimated reading time from markdown source (~200 words per minute).\n */\n\n/** Compute read time in minutes from raw markdown. */\nexport function computeReadTime(rawMarkdown: string): number {\n const plainText = rawMarkdown\n .replace(/```[\\s\\S]*?```/g, ' ')\n .replace(/^( {4}|\\t).+$/gm, ' ')\n .replace(/^---[\\s\\S]*?---/m, ' ')\n .replace(/<[^>]+>/g, ' ')\n .replace(/!?\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/[#*_~`>]/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim()\n const wordCount = plainText.split(' ').filter(Boolean).length\n return Math.max(1, Math.ceil(wordCount / 200))\n}\n","/**\n * ContentEntry — represents a single content entry in a collection.\n *\n * Supports lazy rendering: data is available immediately after loading,\n * but HTML rendering is deferred until render() is called.\n */\n\nimport type { Heading } from './schemas/heading'\nimport type { MarkdownConfig } from './schemas/markdown-config'\nimport { processMarkdown } from './markdown'\nimport { computeReadTime } from './utils/read-time'\n\nexport type RenderedContent = {\n /** Processed HTML */\n html: string\n /** Extracted headings for TOC */\n headings: Heading[]\n /** Estimated read time in minutes */\n readTime: number\n}\n\nexport class ContentEntry<T = Record<string, any>> {\n /** URL-friendly identifier */\n readonly slug: string\n /** Collection this entry belongs to */\n readonly collection: string\n /** Absolute path to source file */\n readonly filePath: string\n /** Validated data (frontmatter or parsed data) */\n readonly data: T\n /** Raw body content (markdown only) */\n readonly rawContent?: string\n\n /** Cached render result */\n private _rendered?: RenderedContent\n /** Markdown config for rendering */\n private _markdownConfig: MarkdownConfig\n\n constructor(\n slug: string,\n collection: string,\n filePath: string,\n data: T,\n rawContent: string | undefined,\n markdownConfig: MarkdownConfig,\n ) {\n this.slug = slug\n this.collection = collection\n this.filePath = filePath\n this.data = data\n this.rawContent = rawContent\n this._markdownConfig = markdownConfig\n }\n\n /** Render the entry content to HTML. Cached after first call. */\n async render(options?: { force?: boolean }): Promise<RenderedContent> {\n if (this._rendered && !options?.force) {\n return this._rendered\n }\n\n if (!this.rawContent) {\n // Non-markdown entries have no renderable content\n this._rendered = { html: '', headings: [], readTime: 0 }\n return this._rendered\n }\n\n const result = await processMarkdown(this.rawContent, this._markdownConfig, {\n content: this.rawContent,\n frontmatter: this.data as Record<string, unknown>,\n })\n const readTime = computeReadTime(this.rawContent)\n\n this._rendered = {\n html: result.html,\n headings: result.headings,\n readTime,\n }\n\n return this._rendered\n }\n\n /** Clear cached render result. */\n clearRenderCache(): void {\n this._rendered = undefined\n }\n}\n","/**\n * Plugin registration and execution.\n */\n\nimport type { ContentPlugin } from '../schemas/content-config'\n\n/** Collect all remark plugins from content plugins. */\nexport function collectRemarkPlugins(plugins: ContentPlugin[]): any[] {\n return plugins.filter((p) => p.remarkPlugin).map((p) => p.remarkPlugin!)\n}\n\n/** Collect all rehype plugins from content plugins. */\nexport function collectRehypePlugins(plugins: ContentPlugin[]): any[] {\n return plugins.filter((p) => p.rehypePlugin).map((p) => p.rehypePlugin!)\n}\n\n/** Run all plugin validators against an entry. */\nexport function runPluginValidators(\n plugins: ContentPlugin[],\n entry: { data: Record<string, any>; content?: string },\n): string[] {\n const issues: string[] = []\n for (const plugin of plugins) {\n if (plugin.validate) {\n issues.push(...plugin.validate(entry))\n }\n }\n return issues\n}\n\nexport type { ContentPlugin } from '../schemas/content-config'\n","/**\n * File discovery via glob patterns.\n */\n\nimport fg from 'fast-glob'\nimport { resolve } from 'path'\n\nexport interface DiscoverOptions {\n /** Directory to search in (absolute path) */\n directory: string\n /** Glob patterns to include */\n include: string[]\n /** Glob patterns to exclude */\n exclude?: string[]\n}\n\n/** Discover files matching glob patterns in a directory. */\nexport function discoverFiles(options: DiscoverOptions): string[] {\n const { directory, include, exclude = [] } = options\n\n return fg\n .sync(include, {\n cwd: directory,\n absolute: true,\n ignore: ['**/node_modules/**', '**/dist/**', '**/dev/**', ...exclude],\n })\n .map((p) => resolve(p))\n}\n","/**\n * Path-to-slug conversion.\n *\n * Generalized from packages/core/src/content/collector.ts.\n */\n\nimport { extname, relative } from 'path'\n\n/**\n * Convert a content file path to a URL-friendly slug.\n *\n * Examples:\n * content/posts/hello-world/README.md -> 'hello-world'\n * content/posts/hello-world/index.md -> 'hello-world'\n * content/posts/hello-world.md -> 'hello-world'\n * content/authors/john.json -> 'john'\n * content/posts/nested/deep/post.md -> 'nested/deep/post'\n */\nexport function toSlug(filePath: string, directory: string): string {\n const ext = extname(filePath)\n let slug = relative(directory, filePath).replace(/\\\\/g, '/')\n\n // Remove file extension\n if (ext) {\n slug = slug.slice(0, -ext.length)\n }\n\n // Strip README / index suffixes\n if (slug === 'README' || slug === 'index') return '/'\n if (slug.endsWith('/README')) slug = slug.slice(0, -7)\n if (slug.endsWith('/index')) slug = slug.slice(0, -6)\n\n return slug\n}\n","/**\n * Schema validation with rich error reporting.\n *\n * Wraps Zod's safeParse to produce human-readable validation issues.\n */\n\nimport type { ZodError, ZodType } from 'zod'\n\nexport type ValidationIssue = {\n /** Field path (e.g. 'tags[0]') */\n field?: string\n /** Human-readable error message */\n message: string\n /** Error severity */\n severity: 'error' | 'warn'\n}\n\nexport type ValidationEntryResult = {\n slug: string\n filePath: string\n issues: ValidationIssue[]\n}\n\nexport type ValidationResult = {\n collection: string\n entries: ValidationEntryResult[]\n errors: number\n warnings: number\n}\n\n/** Format a Zod error path into a human-readable field path. */\nexport function formatPath(path: PropertyKey[]): string {\n return path\n .map((segment, i) => {\n if (typeof segment === 'number') return `[${segment}]`\n if (typeof segment === 'symbol') return `[${String(segment)}]`\n if (i === 0) return segment\n return `.${segment}`\n })\n .join('')\n}\n\n/** Validate data against a Zod schema and return structured issues. */\nexport function validateSchema(\n data: Record<string, any>,\n schema: ZodType,\n): {\n issues: ValidationIssue[]\n validatedData: any\n} {\n const result = schema.safeParse(data)\n if (result.success) {\n return {\n issues: [],\n validatedData: result.data,\n }\n }\n\n return {\n issues: (result.error as ZodError).issues.map((issue) => ({\n field: issue.path.length > 0 ? formatPath(issue.path) : undefined,\n message: issue.message,\n severity: 'error' as const,\n })),\n validatedData: data,\n }\n}\n","/**\n * Code block validator — checks fenced code block meta syntax.\n *\n * Walks the shared MDAST for `code` nodes. Validates known meta properties\n * and language identifiers. Meta syntax follows Expressive Code conventions.\n */\n\nimport type { ValidationIssue } from './schema-validator'\nimport type { ContentValidator, ValidatorContext } from './types'\n\ntype MdastNode = {\n type: string\n lang?: string | null\n meta?: string | null\n value?: string\n children?: MdastNode[]\n position?: { start: { line: number } }\n}\n\n/** Known meta properties accepted by Expressive Code and its plugins. */\nconst KNOWN_META_PROPS = new Set([\n 'title',\n 'showLineNumbers',\n 'startLineNumber',\n 'wrap',\n 'frame',\n 'collapse',\n 'mark',\n 'ins',\n 'del',\n])\n\n/** Extract the property name portion of a meta token (before `=` or `{`). */\nfunction extractMetaPropNames(meta: string): string[] {\n const props: string[] = []\n\n // Match key=value, key={...}, or bare flags\n const tokenRegex = /(\\w+)(?:=(?:\\{[^}]*\\}|\"[^\"]*\"|'[^']*'|\\S+))?/g\n let match: RegExpExecArray | null\n while ((match = tokenRegex.exec(meta)) !== null) {\n props.push(match[1]!)\n }\n\n return props\n}\n\n/** Collect all `code` nodes from MDAST. */\nfunction collectCodeBlocks(node: MdastNode): MdastNode[] {\n const blocks: MdastNode[] = []\n\n if (node.type === 'code') {\n blocks.push(node)\n }\n\n if (node.children) {\n for (const child of node.children) {\n blocks.push(...collectCodeBlocks(child))\n }\n }\n\n return blocks\n}\n\nexport const codeBlockValidator: ContentValidator = {\n name: 'code-blocks',\n\n validate(ctx: ValidatorContext): ValidationIssue[] {\n if (!ctx.rawContent || !ctx.mdast) return []\n\n const issues: ValidationIssue[] = []\n const tree = ctx.mdast as MdastNode\n\n const codeBlocks = collectCodeBlocks(tree)\n\n for (const block of codeBlocks) {\n const line = block.position?.start.line\n const lineInfo = line ? ` (line ${line})` : ''\n const meta = block.meta ?? ''\n const hasMeta = meta.trim().length > 0\n\n // Language required when using syntax features\n if (hasMeta && !block.lang) {\n issues.push({\n field: `code-block${lineInfo}`,\n message: 'Code block has meta properties but no language identifier',\n severity: 'warn',\n })\n }\n\n if (!hasMeta) continue\n\n // Check for unknown meta properties\n const propNames = extractMetaPropNames(meta)\n for (const prop of propNames) {\n if (!KNOWN_META_PROPS.has(prop)) {\n issues.push({\n field: `code-block${lineInfo}`,\n message: `Unknown code block meta property: \"${prop}\"`,\n severity: 'warn',\n })\n }\n }\n }\n\n return issues\n },\n}\n","/**\n * Heading validator — checks heading structure in markdown.\n *\n * Walks the shared MDAST for heading nodes. Validates level ordering and h1 uniqueness.\n */\n\nimport type { ValidationIssue } from './schema-validator'\nimport type { ContentValidator, ValidatorContext } from './types'\n\ntype MdastNode = {\n type: string\n depth?: number\n children?: MdastNode[]\n position?: { start: { line: number } }\n value?: string\n}\n\n/** Extract plain text from a heading node's children. */\nfunction getTextContent(node: MdastNode): string {\n if (node.type === 'text') return node.value ?? ''\n if (node.children) return node.children.map(getTextContent).join('')\n return ''\n}\n\n/** Collect all heading nodes from MDAST. */\nfunction collectHeadings(node: MdastNode): Array<{ depth: number; text: string; line?: number }> {\n const headings: Array<{ depth: number; text: string; line?: number }> = []\n\n if (node.type === 'heading' && node.depth) {\n headings.push({\n depth: node.depth,\n text: getTextContent(node),\n line: node.position?.start.line,\n })\n }\n\n if (node.children) {\n for (const child of node.children) {\n headings.push(...collectHeadings(child))\n }\n }\n\n return headings\n}\n\nexport const headingValidator: ContentValidator = {\n name: 'headings',\n\n validate(ctx: ValidatorContext): ValidationIssue[] {\n if (!ctx.rawContent || !ctx.mdast) return []\n\n const issues: ValidationIssue[] = []\n const tree = ctx.mdast as MdastNode\n\n const headings = collectHeadings(tree)\n\n // No headings in a document with content is worth noting\n if (headings.length === 0) {\n const hasContent = ctx.rawContent.trim().length > 0\n if (hasContent) {\n issues.push({\n message: 'Document has content but no headings',\n severity: 'warn',\n })\n }\n return issues\n }\n\n // At most one h1\n const h1s = headings.filter((h) => h.depth === 1)\n if (h1s.length > 1) {\n for (const h of h1s.slice(1)) {\n const lineInfo = h.line ? ` (line ${h.line})` : ''\n issues.push({\n field: `headings${lineInfo}`,\n message: `Multiple h1 headings found: \"${h.text}\"`,\n severity: 'warn',\n })\n }\n }\n\n // No skipped levels (only flag when going deeper)\n for (let i = 1; i < headings.length; i++) {\n const prev = headings[i - 1]!\n const curr = headings[i]!\n if (curr.depth > prev.depth + 1) {\n const lineInfo = curr.line ? ` (line ${curr.line})` : ''\n issues.push({\n field: `headings${lineInfo}`,\n message: `Heading level skip: h${prev.depth} -> h${curr.depth} (\"${curr.text}\")`,\n severity: 'warn',\n })\n }\n }\n\n return issues\n },\n}\n","/**\n * Link validator — checks links in markdown content.\n *\n * Walks the shared MDAST for link/image nodes. Internal links are checked for file existence;\n * external links are checked for well-formed URL format.\n */\n\nimport { existsSync } from 'fs'\nimport { dirname, resolve } from 'path'\nimport type { ValidationIssue } from './schema-validator'\nimport type { ContentValidator, ValidatorContext } from './types'\n\ntype MdastNode = {\n type: string\n url?: string\n children?: MdastNode[]\n position?: { start: { line: number } }\n}\n\n/** Walk MDAST tree, collecting link and image nodes. */\nfunction collectLinks(node: MdastNode): Array<{ url: string; line?: number }> {\n const links: Array<{ url: string; line?: number }> = []\n\n if ((node.type === 'link' || node.type === 'image') && node.url) {\n links.push({\n url: node.url,\n line: node.position?.start.line,\n })\n }\n\n if (node.children) {\n for (const child of node.children) {\n links.push(...collectLinks(child))\n }\n }\n\n return links\n}\n\nfunction isInternalLink(url: string): boolean {\n if (url.startsWith('#')) return false\n if (url.startsWith('http://') || url.startsWith('https://')) return false\n if (url.startsWith('//')) return false\n if (url.startsWith('mailto:')) return false\n if (url.startsWith('tel:')) return false\n return true\n}\n\nfunction isWellFormedUrl(url: string): boolean {\n try {\n new URL(url)\n return true\n } catch {\n return false\n }\n}\n\nexport const linkValidator: ContentValidator = {\n name: 'links',\n\n validate(ctx: ValidatorContext): ValidationIssue[] {\n if (!ctx.rawContent || !ctx.mdast) return []\n\n const issues: ValidationIssue[] = []\n const tree = ctx.mdast as MdastNode\n\n const links = collectLinks(tree)\n const fileDir = dirname(ctx.filePath)\n\n for (const link of links) {\n const lineInfo = link.line ? ` (line ${link.line})` : ''\n\n // External links — check URL format\n if (link.url.startsWith('http://') || link.url.startsWith('https://')) {\n if (!isWellFormedUrl(link.url)) {\n issues.push({\n field: `links${lineInfo}`,\n message: `Malformed external URL: ${link.url}`,\n severity: 'warn',\n })\n }\n continue\n }\n\n // Internal links — check file exists\n if (isInternalLink(link.url)) {\n // Strip fragment and query\n const urlPath = link.url.split('#')[0]!.split('?')[0]!\n if (!urlPath) continue // pure fragment link\n\n const resolved = resolve(fileDir, urlPath)\n if (!existsSync(resolved)) {\n issues.push({\n field: `links${lineInfo}`,\n message: `Broken internal link: ${link.url}`,\n severity: 'error',\n })\n }\n }\n }\n\n return issues\n },\n}\n","/**\n * Validation runner — executes a list of content validators on an entry.\n *\n * Validators that throw are caught and converted to error-severity issues\n * so one failing validator does not block the rest.\n */\n\nimport remarkParse from 'remark-parse'\nimport { unified } from 'unified'\nimport type { ValidationIssue } from './schema-validator'\nimport type { ContentValidator, ValidatorContext } from './types'\n\nimport { codeBlockValidator } from './code-block-validator'\nimport { headingValidator } from './heading-validator'\nimport { linkValidator } from './link-validator'\n\n/** The built-in validators for markdown content. */\nexport const builtinMarkdownValidators: ContentValidator[] = [\n linkValidator,\n codeBlockValidator,\n headingValidator,\n]\n\n/** Run all validators on a single content entry. */\nexport async function runValidators(\n ctx: ValidatorContext,\n validators: ContentValidator[],\n): Promise<ValidationIssue[]> {\n if (ctx.rawContent && !ctx.mdast) {\n ctx.mdast = unified().use(remarkParse).parse(ctx.rawContent)\n }\n\n const issues: ValidationIssue[] = []\n\n for (const validator of validators) {\n try {\n const result = await validator.validate(ctx)\n issues.push(...result)\n } catch (err) {\n // Convert thrown errors into issues so one bad validator doesn't abort all\n const message = err instanceof Error ? err.message : String(err)\n issues.push({\n message: `Validator \"${validator.name}\" threw: ${message}`,\n severity: 'error',\n })\n }\n }\n\n return issues\n}\n","/**\n * ContentStore — in-memory cache for loaded collections.\n *\n * Handles file discovery, loading, validation, and caching.\n * Not exported directly — used internally by ContentLayer.\n */\n\nimport { resolve } from 'path'\nimport type { MarkdownConfig } from './schemas/markdown-config'\nimport type { ZodType } from 'zod'\nimport { ContentEntry } from './entry'\nimport { defaultIncludePatterns, resolveLoader } from './loaders'\nimport type { Loader } from './loaders/types'\nimport { collectRehypePlugins, collectRemarkPlugins, runPluginValidators } from './plugins'\nimport type { CollectionDef, RawEntry } from './schemas/collection'\nimport type { ContentLayerConfig } from './schemas/content-config'\nimport { discoverFiles } from './utils/glob'\nimport { toSlug } from './utils/slug'\nimport { validateSchema, type ValidationIssue } from './validation'\nimport { builtinMarkdownValidators, runValidators } from './validation/runner'\nimport type { ContentValidator } from './validation/types'\n\ntype CacheEntry = {\n entry: ContentEntry<any>\n issues: ValidationIssue[]\n}\n\nexport class ContentStore {\n private cache = new Map<string, Map<string, CacheEntry>>()\n private loaded = new Set<string>()\n private config: ContentLayerConfig\n private rootDir: string\n private markdownConfig: MarkdownConfig\n\n constructor(config: ContentLayerConfig) {\n this.config = config\n this.rootDir = config.root ? resolve(config.root) : process.cwd()\n this.markdownConfig = this.createMarkdownConfig()\n }\n\n /** Load a collection (if not already loaded) and return entries. */\n async loadCollection<S extends ZodType>(\n name: string,\n def: CollectionDef<S>,\n ): Promise<ContentEntry<any>[]> {\n if (this.loaded.has(name)) {\n const cached = this.cache.get(name)\n return cached ? Array.from(cached.values()).map((c) => c.entry) : []\n }\n\n const loader = resolveLoader(def.loader)\n const directory = resolve(this.rootDir, def.directory)\n const include = def.include ?? defaultIncludePatterns(loader)\n\n const files = discoverFiles({\n directory,\n include,\n exclude: def.exclude,\n })\n\n const entries = new Map<string, CacheEntry>()\n const results = await Promise.all(\n files.map(async (filePath) => {\n try {\n return await this.loadEntry(name, filePath, directory, loader, def)\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n const slug = def.slugify ? def.slugify(filePath, directory) : toSlug(filePath, directory)\n return {\n entry: new ContentEntry(slug, name, filePath, {}, undefined, this.markdownConfig),\n issues: [{ message: `Failed to load: ${message}`, severity: 'error' as const }],\n }\n }\n }),\n )\n\n for (const result of results) {\n if (result) {\n entries.set(result.entry.slug, result)\n }\n }\n\n this.cache.set(name, entries)\n this.loaded.add(name)\n\n return Array.from(entries.values()).map((c) => c.entry)\n }\n\n /** Load a single entry from a file. */\n private async loadEntry(\n collectionName: string,\n filePath: string,\n directory: string,\n loader: Loader,\n def: CollectionDef<any>,\n ): Promise<CacheEntry | null> {\n const loaded = await loader.load(filePath)\n const slug = def.slugify ? def.slugify(filePath, directory) : toSlug(filePath, directory)\n\n let raw: RawEntry = {\n data: loaded.data,\n content: loaded.content,\n filePath,\n slug,\n }\n\n // Apply transform\n if (def.transform) {\n raw = await def.transform(raw)\n }\n\n // Apply computed fields\n if (def.computed) {\n for (const [key, fn] of Object.entries(def.computed) as Array<\n [string, (entry: RawEntry) => any]\n >) {\n raw.data[key] = fn(raw)\n }\n }\n\n // Apply filter\n if (def.filter && !def.filter(raw)) {\n return null\n }\n\n // Validate schema once to collect issues and transformed data.\n const { issues, validatedData } = validateSchema(raw.data, def.schema)\n\n // Custom validation\n if (def.validate) {\n const customError = def.validate(raw)\n if (customError) {\n issues.push({ message: customError, severity: 'error' })\n }\n }\n\n // Run content validators on markdown entries\n const isMarkdownEntry = raw.content !== undefined\n if (isMarkdownEntry) {\n const validators = this.resolveValidators(def)\n if (validators.length > 0) {\n const contentIssues = await runValidators(\n {\n filePath,\n slug,\n collection: collectionName,\n rawContent: raw.content,\n data: raw.data,\n },\n validators,\n )\n issues.push(...contentIssues)\n }\n }\n\n if (this.config.plugins?.length) {\n const pluginIssues = runPluginValidators(this.config.plugins, {\n data: raw.data,\n content: raw.content,\n })\n for (const message of pluginIssues) {\n issues.push({ message, severity: 'error' })\n }\n }\n\n const entry = new ContentEntry(\n slug,\n collectionName,\n filePath,\n validatedData,\n raw.content,\n this.markdownConfig,\n )\n\n return { entry, issues }\n }\n\n /** Get a single entry by slug. */\n getEntry(collection: string, slug: string): ContentEntry<any> | undefined {\n return this.cache.get(collection)?.get(slug)?.entry\n }\n\n /** Get validation issues for a collection. */\n getIssues(collection: string): Map<string, ValidationIssue[]> {\n const result = new Map<string, ValidationIssue[]>()\n const entries = this.cache.get(collection)\n if (!entries) return result\n for (const [slug, cached] of entries) {\n if (cached.issues.length > 0) {\n result.set(slug, cached.issues)\n }\n }\n return result\n }\n\n /** Invalidate a single entry (forces full collection reload on next access). */\n invalidate(collection: string, slug: string): void {\n this.cache.get(collection)?.delete(slug)\n this.loaded.delete(collection)\n }\n\n /** Invalidate an entire collection. */\n invalidateCollection(collection: string): void {\n this.cache.delete(collection)\n this.loaded.delete(collection)\n }\n\n /** Invalidate all collections. */\n invalidateAll(): void {\n this.cache.clear()\n this.loaded.clear()\n }\n\n /** Resolve the list of content validators for a collection. */\n private resolveValidators(def: CollectionDef<any>): ContentValidator[] {\n const builtin = def.disableBuiltinValidators ? [] : builtinMarkdownValidators\n const custom = def.validators ?? []\n return [...builtin, ...custom]\n }\n\n private createMarkdownConfig(): MarkdownConfig {\n const base = this.config.markdown ?? {}\n const remarkPlugins = [...(base.remarkPlugins ?? [])]\n const rehypePlugins = [...(base.rehypePlugins ?? [])]\n const plugins = this.config.plugins ?? []\n\n if (plugins.length > 0) {\n remarkPlugins.push(...collectRemarkPlugins(plugins))\n rehypePlugins.push(...collectRehypePlugins(plugins))\n }\n\n return {\n ...base,\n ...(remarkPlugins.length > 0 ? { remarkPlugins } : {}),\n ...(rehypePlugins.length > 0 ? { rehypePlugins } : {}),\n }\n }\n}\n","/**\n * ContentLayer — the main API for working with content collections.\n *\n * Created via createContentLayer(config). Provides methods to:\n * - Load and query collections (getCollection, getEntry)\n * - Convert markdown directly (convert)\n * - Invalidate cache (invalidate, invalidateCollection, invalidateAll)\n * - Validate all entries (validate)\n */\n\nimport type { ConvertResult } from './convert'\nimport type { MarkdownConfig } from './schemas/markdown-config'\nimport type { ContentEntry } from './entry'\nimport type { CollectionDef } from './schemas/collection'\nimport type { ContentLayerConfig } from './schemas/content-config'\nimport { ContentStore } from './store'\nimport type { ValidationResult } from './validation'\n\nexport interface ContentLayer {\n /** Get all entries in a collection. */\n getCollection(name: string): Promise<ContentEntry<any>[]>\n\n /** Get a single entry by collection name and slug. */\n getEntry(collection: string, slug: string): Promise<ContentEntry<any> | undefined>\n\n /** Convert raw markdown to HTML (no collection, no validation). */\n convert(markdown: string, options?: LayerConvertOptions): Promise<ConvertResult>\n\n /** Invalidate a single entry's cache. */\n invalidate(collection: string, slug: string): void\n\n /** Invalidate an entire collection's cache. */\n invalidateCollection(collection: string): void\n\n /** Invalidate all cached data. */\n invalidateAll(): void\n\n /** Validate all entries in a collection (or all collections). */\n validate(collection?: string): Promise<ValidationResult[]>\n\n /** Get the names of all configured collections. */\n getCollectionNames(): string[]\n\n /** Get the definition of a collection. */\n getCollectionDef(name: string): CollectionDef | undefined\n}\n\nexport type LayerConvertOptions = {\n markdown?: MarkdownConfig\n}\n\nclass ContentLayerImpl implements ContentLayer {\n private store: ContentStore\n private config: ContentLayerConfig\n\n constructor(config: ContentLayerConfig) {\n this.config = config\n this.store = new ContentStore(config)\n }\n\n async getCollection(name: string): Promise<ContentEntry<any>[]> {\n const def = this.config.collections[name]\n if (!def) {\n throw new Error(\n `Collection \"${name}\" not found. Available: ${Object.keys(this.config.collections).join(\n ', ',\n )}`,\n )\n }\n return this.store.loadCollection(name, def)\n }\n\n async getEntry(collection: string, slug: string): Promise<ContentEntry<any> | undefined> {\n // The first getEntry call loads the full collection and then serves from cache.\n // Single-entry loading would skip collection-level transforms and validation context.\n await this.getCollection(collection)\n return this.store.getEntry(collection, slug)\n }\n\n async convert(markdown: string, options?: LayerConvertOptions): Promise<ConvertResult> {\n const { convert: coreConvert } = await import('./convert.js')\n return coreConvert(markdown, {\n markdown: options?.markdown ?? this.config.markdown,\n })\n }\n\n invalidate(collection: string, slug: string): void {\n this.store.invalidate(collection, slug)\n }\n\n invalidateCollection(collection: string): void {\n this.store.invalidateCollection(collection)\n }\n\n invalidateAll(): void {\n this.store.invalidateAll()\n }\n\n async validate(collection?: string): Promise<ValidationResult[]> {\n const names = collection ? [collection] : Object.keys(this.config.collections)\n const results: ValidationResult[] = []\n\n for (const name of names) {\n // Ensure loaded\n await this.getCollection(name)\n\n const issues = this.store.getIssues(name)\n const entries = Array.from(issues.entries()).map(([slug, entryIssues]) => {\n const entry = this.store.getEntry(name, slug)\n return {\n slug,\n filePath: entry?.filePath ?? '',\n issues: entryIssues,\n }\n })\n\n let errors = 0\n let warnings = 0\n for (const entry of entries) {\n for (const issue of entry.issues) {\n if (issue.severity === 'error') errors++\n else warnings++\n }\n }\n\n results.push({ collection: name, entries, errors, warnings })\n }\n\n return results\n }\n\n getCollectionNames(): string[] {\n return Object.keys(this.config.collections)\n }\n\n getCollectionDef(name: string): CollectionDef | undefined {\n return this.config.collections[name]\n }\n}\n\n/** Create a new content layer from a configuration. */\nexport function createContentLayer(config: ContentLayerConfig): ContentLayer {\n return new ContentLayerImpl(config)\n}\n"],"mappings":";;;;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M,aAAa,QAAS;OAC3B;AAIT,WAAQ,KAAK;IAAE,YAAY;IAAM;IAAS;IAAQ;IAAU,CAAC;;AAG/D,SAAO;;CAGT,qBAA+B;AAC7B,SAAO,OAAO,KAAK,KAAK,OAAO,YAAY;;CAG7C,iBAAiB,MAAyC;AACxD,SAAO,KAAK,OAAO,YAAY;;;;AAKnC,SAAgB,mBAAmB,QAA0C;AAC3E,QAAO,IAAI,iBAAiB,OAAO"}
@@ -0,0 +1,52 @@
1
+ import { t as processMarkdown } from "./markdown-Cj5X26FL.mjs";
2
+ //#region \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ //#endregion
14
+ //#region src/toc.ts
15
+ /**
16
+ * Extract table of contents headings from an HTML string.
17
+ *
18
+ * Regex-based: finds <h[1-6] id="...">text</h[1-6]>, strips inner HTML tags.
19
+ * No dependency on unified — works on any HTML string.
20
+ */
21
+ function extractToc(html) {
22
+ const headings = [];
23
+ const re = /<h([1-6])\s+id="([^"]*)"[^>]*>([\s\S]*?)<\/h\1>/gi;
24
+ let match;
25
+ while ((match = re.exec(html)) !== null) {
26
+ const depth = parseInt(match[1], 10);
27
+ const slug = match[2];
28
+ const text = match[3].replace(/<[^>]+>/g, "").trim();
29
+ headings.push({
30
+ depth,
31
+ text,
32
+ slug
33
+ });
34
+ }
35
+ return headings;
36
+ }
37
+ //#endregion
38
+ //#region src/convert.ts
39
+ var convert_exports = /* @__PURE__ */ __exportAll({ convert: () => convert });
40
+ async function convert(input, options = {}) {
41
+ const result = await processMarkdown(input, options.markdown || {});
42
+ const toc = extractToc(result.html);
43
+ return {
44
+ html: result.html,
45
+ toc,
46
+ frontmatter: result.frontmatter
47
+ };
48
+ }
49
+ //#endregion
50
+ export { convert_exports as n, extractToc as r, convert as t };
51
+
52
+ //# sourceMappingURL=convert-DnuB6SVV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-DnuB6SVV.mjs","names":[],"sources":["../src/toc.ts","../src/convert.ts"],"sourcesContent":["import type { Heading } from './schemas/heading'\n\n/**\n * Extract table of contents headings from an HTML string.\n *\n * Regex-based: finds <h[1-6] id=\"...\">text</h[1-6]>, strips inner HTML tags.\n * No dependency on unified — works on any HTML string.\n */\nexport function extractToc(html: string): Heading[] {\n const headings: Heading[] = []\n const re = /<h([1-6])\\s+id=\"([^\"]*)\"[^>]*>([\\s\\S]*?)<\\/h\\1>/gi\n let match: RegExpExecArray | null\n\n while ((match = re.exec(html)) !== null) {\n const depth = parseInt(match[1], 10)\n const slug = match[2]\n // Strip inner HTML tags to get plain text\n const text = match[3].replace(/<[^>]+>/g, '').trim()\n headings.push({ depth, text, slug })\n }\n\n return headings\n}\n","import { processMarkdown } from './markdown'\nimport type { Heading } from './schemas/heading'\nimport type { MarkdownConfig } from './schemas/markdown-config'\nimport { extractToc } from './toc'\n\nexport type ConvertOptions = {\n markdown?: MarkdownConfig\n}\n\nexport type ConvertResult = {\n html: string\n toc: Heading[]\n frontmatter: Record<string, any>\n}\n\nexport async function convert(input: string, options: ConvertOptions = {}): Promise<ConvertResult> {\n const result = await processMarkdown(input, options.markdown || {})\n const toc = extractToc(result.html)\n return { html: result.html, toc, frontmatter: result.frontmatter }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQA,SAAgB,WAAW,MAAyB;CAClD,MAAM,WAAsB,EAAE;CAC9B,MAAM,KAAK;CACX,IAAI;AAEJ,SAAQ,QAAQ,GAAG,KAAK,KAAK,MAAM,MAAM;EACvC,MAAM,QAAQ,SAAS,MAAM,IAAI,GAAG;EACpC,MAAM,OAAO,MAAM;EAEnB,MAAM,OAAO,MAAM,GAAG,QAAQ,YAAY,GAAG,CAAC,MAAM;AACpD,WAAS,KAAK;GAAE;GAAO;GAAM;GAAM,CAAC;;AAGtC,QAAO;;;;;ACNT,eAAsB,QAAQ,OAAe,UAA0B,EAAE,EAA0B;CACjG,MAAM,SAAS,MAAM,gBAAgB,OAAO,QAAQ,YAAY,EAAE,CAAC;CACnE,MAAM,MAAM,WAAW,OAAO,KAAK;AACnC,QAAO;EAAE,MAAM,OAAO;EAAM;EAAK,aAAa,OAAO;EAAa"}
@@ -0,0 +1,20 @@
1
+ //#region src/create/index.d.ts
2
+ /**
3
+ * Project scaffolding for `pagesmith create`.
4
+ *
5
+ * Supports local templates (bundled) and remote templates (GitHub examples).
6
+ */
7
+ type Template = {
8
+ name: string;
9
+ description: string;
10
+ source: 'local' | 'github';
11
+ path: string;
12
+ dependency: '@pagesmith/core' | '@pagesmith/docs';
13
+ scripts: Record<string, string>;
14
+ };
15
+ declare const templates: Template[];
16
+ declare function listTemplates(): string;
17
+ declare function createProject(projectName: string, templateName: string): Promise<void>;
18
+ //#endregion
19
+ export { Template, createProject, listTemplates, templates };
20
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/create/index.ts"],"mappings":";;AAwBA;;;;KAAY,QAAA;EACV,IAAA;EACA,WAAA;EACA,MAAA;EACA,IAAA;EACA,UAAA;EACA,OAAA,EAAS,MAAA;AAAA;AAAA,cAGE,SAAA,EAAW,QAAA;AAAA,iBA6ER,aAAA,CAAA;AAAA,iBAmKM,aAAA,CAAc,WAAA,UAAqB,YAAA,WAAuB,OAAA"}
@@ -0,0 +1,215 @@
1
+ import { join, resolve } from "path";
2
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, unlinkSync, writeFileSync } from "fs";
3
+ import { tmpdir } from "os";
4
+ import { execSync } from "child_process";
5
+ //#region src/create/index.ts
6
+ /**
7
+ * Project scaffolding for `pagesmith create`.
8
+ *
9
+ * Supports local templates (bundled) and remote templates (GitHub examples).
10
+ */
11
+ const GITHUB_REPO = "sujeet-pro/pagesmith";
12
+ const PACKAGE_VERSION = "^0.1.0";
13
+ const templates = [
14
+ {
15
+ name: "docs",
16
+ description: "Documentation site with @pagesmith/docs",
17
+ source: "local",
18
+ path: "templates/docs",
19
+ dependency: "@pagesmith/docs",
20
+ scripts: {
21
+ dev: "pagesmith dev",
22
+ build: "pagesmith build",
23
+ preview: "pagesmith preview"
24
+ }
25
+ },
26
+ {
27
+ name: "blog",
28
+ description: "Blog with custom layouts using @pagesmith/core",
29
+ source: "github",
30
+ path: "examples/blog-site",
31
+ dependency: "@pagesmith/core",
32
+ scripts: {
33
+ dev: "node --watch build.mjs",
34
+ build: "node build.mjs"
35
+ }
36
+ },
37
+ {
38
+ name: "react",
39
+ description: "React SSG site with react-router",
40
+ source: "github",
41
+ path: "examples/with-react",
42
+ dependency: "@pagesmith/core",
43
+ scripts: {
44
+ dev: "vp dev",
45
+ build: "node build.mjs",
46
+ preview: "vp preview"
47
+ }
48
+ },
49
+ {
50
+ name: "solid",
51
+ description: "SolidJS SSG site",
52
+ source: "github",
53
+ path: "examples/with-solid",
54
+ dependency: "@pagesmith/core",
55
+ scripts: {
56
+ dev: "vp dev",
57
+ build: "node build.mjs",
58
+ preview: "vp preview"
59
+ }
60
+ },
61
+ {
62
+ name: "svelte",
63
+ description: "Svelte SSG site",
64
+ source: "github",
65
+ path: "examples/with-svelte",
66
+ dependency: "@pagesmith/core",
67
+ scripts: {
68
+ dev: "vp dev",
69
+ build: "node build.mjs",
70
+ preview: "vp preview"
71
+ }
72
+ },
73
+ {
74
+ name: "ejs",
75
+ description: "Vanilla Node.js + EJS templates",
76
+ source: "github",
77
+ path: "examples/with-vanilla-ejs",
78
+ dependency: "@pagesmith/core",
79
+ scripts: {
80
+ dev: "node --watch build.mjs",
81
+ build: "node build.mjs"
82
+ }
83
+ },
84
+ {
85
+ name: "hbs",
86
+ description: "Vanilla Node.js + Handlebars templates",
87
+ source: "github",
88
+ path: "examples/with-vanilla-hbs",
89
+ dependency: "@pagesmith/core",
90
+ scripts: {
91
+ dev: "node --watch build.mjs",
92
+ build: "node build.mjs"
93
+ }
94
+ }
95
+ ];
96
+ function listTemplates() {
97
+ const maxName = Math.max(...templates.map((t) => t.name.length));
98
+ return templates.map((t) => ` ${t.name.padEnd(maxName + 2)} ${t.description}`).join("\n");
99
+ }
100
+ async function downloadFromGithub(templatePath, destination) {
101
+ const tarballUrl = `https://github.com/${GITHUB_REPO}/archive/refs/heads/main.tar.gz`;
102
+ console.log("Downloading template from GitHub...");
103
+ const response = await fetch(tarballUrl, { redirect: "follow" });
104
+ if (!response.ok) throw new Error(`Failed to download: ${response.status} ${response.statusText}`);
105
+ const tmpFile = join(tmpdir(), `pagesmith-${Date.now()}.tar.gz`);
106
+ const tmpExtract = mkdtempSync(join(tmpdir(), "pagesmith-"));
107
+ try {
108
+ writeFileSync(tmpFile, Buffer.from(await response.arrayBuffer()));
109
+ execSync(`tar xzf ${tmpFile} -C ${tmpExtract}`, { stdio: "pipe" });
110
+ const topDir = readdirSync(tmpExtract)[0];
111
+ if (!topDir) throw new Error("Empty tarball");
112
+ const sourcePath = join(tmpExtract, topDir, templatePath);
113
+ if (!existsSync(sourcePath)) throw new Error(`Template path not found in repo: ${templatePath}`);
114
+ mkdirSync(destination, { recursive: true });
115
+ 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
+ } finally {
132
+ unlinkSync(tmpFile);
133
+ rmSync(tmpExtract, {
134
+ recursive: true,
135
+ force: true
136
+ });
137
+ }
138
+ }
139
+ function adaptForStandalone(destination, template) {
140
+ const configPath = join(destination, "content.config.mjs");
141
+ if (existsSync(configPath)) {
142
+ let config = readFileSync(configPath, "utf-8");
143
+ config = config.replace(/directory: '\.\/posts'/g, "directory: './content/posts'");
144
+ config = config.replace(/directory: '\.\/pages'/g, "directory: './content/pages'");
145
+ config = config.replace(/directory: '\.\/authors'/g, "directory: './content/authors'");
146
+ config = config.replace(/directory: '\.\/config'/g, "directory: './content/config'");
147
+ writeFileSync(configPath, config);
148
+ }
149
+ const viteConfigPath = join(destination, "vite.config.ts");
150
+ if (existsSync(viteConfigPath)) {
151
+ let config = readFileSync(viteConfigPath, "utf-8");
152
+ config = config.replace(/import content from '\.\.\/shared-content\/content\.config'/g, "import content from './content.config.mjs'");
153
+ config = config.replace(/configPath:\s*'\.\.\/shared-content\/content\.config\.ts'/g, "configPath: './content.config.mjs'");
154
+ config = config.replace(/root:\s*resolve\(import\.meta\.dirname,\s*'\.\.\/shared-content'\)/g, "root: import.meta.dirname");
155
+ writeFileSync(viteConfigPath, config);
156
+ }
157
+ const buildPath = join(destination, "build.mjs");
158
+ if (existsSync(buildPath)) {
159
+ let script = readFileSync(buildPath, "utf-8");
160
+ script = script.replace(/import .* from '\.\.\/shared-content\/content\.config\.mjs'/g, "import content from './content.config.mjs'");
161
+ script = script.replace(/const contentRoot = resolve\(root, '\.\.\/shared-content'\)/g, "const contentRoot = root");
162
+ script = script.replace(/import \{ pages, posts \} from '\.\.\/shared-content\/content\.config\.mjs'/g, "import content from './content.config.mjs'\nconst { pages, posts } = content");
163
+ writeFileSync(buildPath, script);
164
+ }
165
+ const tsconfigPath = join(destination, "tsconfig.json");
166
+ if (existsSync(tsconfigPath)) {
167
+ const tsconfig = JSON.parse(readFileSync(tsconfigPath, "utf-8"));
168
+ if (tsconfig.compilerOptions?.paths) delete tsconfig.compilerOptions.paths;
169
+ writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + "\n");
170
+ }
171
+ }
172
+ function writePackageJson(destination, projectName, template) {
173
+ const existingPkg = join(destination, "package.json");
174
+ let pkg = {};
175
+ if (existsSync(existingPkg)) pkg = JSON.parse(readFileSync(existingPkg, "utf-8"));
176
+ pkg.name = projectName;
177
+ pkg.private = true;
178
+ pkg.type = "module";
179
+ pkg.version = "0.0.0";
180
+ pkg.scripts = template.scripts;
181
+ if (pkg.dependencies) {
182
+ for (const [name, version] of Object.entries(pkg.dependencies)) if (version === "*" && name.startsWith("@pagesmith/")) pkg.dependencies[name] = PACKAGE_VERSION;
183
+ }
184
+ pkg.dependencies = pkg.dependencies ?? {};
185
+ pkg.dependencies[template.dependency] = PACKAGE_VERSION;
186
+ if (pkg.devDependencies?.vite && !pkg.devDependencies["vite-plus"]) pkg.devDependencies["vite-plus"] = "^0.1.13";
187
+ pkg.packageManager = "npm@11.12.0";
188
+ writeFileSync(existingPkg, JSON.stringify(pkg, null, 2) + "\n");
189
+ }
190
+ async function createProject(projectName, templateName) {
191
+ const template = templates.find((t) => t.name === templateName);
192
+ if (!template) throw new Error(`Unknown template "${templateName}". Available templates:\n${listTemplates()}`);
193
+ const destination = resolve(projectName);
194
+ if (existsSync(destination) && readdirSync(destination).length > 0) throw new Error(`Directory "${projectName}" already exists and is not empty.`);
195
+ if (template.source === "local") {
196
+ const templateDir = resolve(import.meta.dirname, "../../templates", template.path.split("/").pop());
197
+ mkdirSync(destination, { recursive: true });
198
+ cpSync(templateDir, destination, { recursive: true });
199
+ } else {
200
+ await downloadFromGithub(template.path, destination);
201
+ adaptForStandalone(destination, template);
202
+ }
203
+ writePackageJson(destination, projectName, template);
204
+ console.log(`\nCreated "${projectName}" from the "${template.name}" template.\n`);
205
+ console.log("Next steps:");
206
+ console.log(` cd ${projectName}`);
207
+ console.log(" vp install");
208
+ if (template.scripts.dev) console.log(` vp run dev`);
209
+ else console.log(` vp run build`);
210
+ console.log();
211
+ }
212
+ //#endregion
213
+ export { createProject, listTemplates, templates };
214
+
215
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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,OAAO;GAAkB;EACpE;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GACP,KAAK;GACL,OAAO;GACP,SAAS;GACV;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GACP,KAAK;GACL,OAAO;GACP,SAAS;GACV;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAAY;EACZ,SAAS;GACP,KAAK;GACL,OAAO;GACP,SAAS;GACV;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,QAAQ;EACR,MAAM;EACN,YAA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AS,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"}
@@ -0,0 +1,2 @@
1
+ import { t as buildCss } from "../index-CeNDTM-y.mjs";
2
+ export { buildCss };
@@ -0,0 +1,2 @@
1
+ import { t as buildCss } from "../css-ekIt2Fdb.mjs";
2
+ export { buildCss };
@@ -0,0 +1,19 @@
1
+ import { resolve } from "path";
2
+ import { bundle } from "lightningcss";
3
+ //#region src/css/builder.ts
4
+ function buildCss(entryPath, config) {
5
+ const { code } = bundle({
6
+ filename: resolve(entryPath),
7
+ minify: config?.minify ?? true,
8
+ targets: {
9
+ chrome: 8060928,
10
+ firefox: 7864320,
11
+ safari: 18 << 16
12
+ }
13
+ });
14
+ return new TextDecoder().decode(code);
15
+ }
16
+ //#endregion
17
+ export { buildCss as t };
18
+
19
+ //# sourceMappingURL=css-ekIt2Fdb.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-ekIt2Fdb.mjs","names":[],"sources":["../src/css/builder.ts"],"sourcesContent":["import { bundle } from 'lightningcss'\nimport { resolve } from 'path'\n\nexport function buildCss(entryPath: string, config?: { minify?: boolean }): string {\n const { code } = bundle({\n filename: resolve(entryPath),\n minify: config?.minify ?? true,\n targets: {\n chrome: 123 << 16,\n firefox: 120 << 16,\n safari: 18 << 16,\n },\n })\n return new TextDecoder().decode(code)\n}\n"],"mappings":";;;AAGA,SAAgB,SAAS,WAAmB,QAAuC;CACjF,MAAM,EAAE,SAAS,OAAO;EACtB,UAAU,QAAQ,UAAU;EAC5B,QAAQ,QAAQ,UAAU;EAC1B,SAAS;GACP,QAAQ;GACR,SAAS;GACT,QAAQ,MAAM;GACf;EACF,CAAC;AACF,QAAO,IAAI,aAAa,CAAC,OAAO,KAAK"}
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/schemas/markdown-config.d.ts
4
+ declare const MarkdownConfigSchema: z.ZodObject<{
5
+ remarkPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
6
+ rehypePlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
7
+ shiki: z.ZodOptional<z.ZodObject<{
8
+ themes: z.ZodObject<{
9
+ light: z.ZodString;
10
+ dark: z.ZodString;
11
+ }, z.core.$strip>;
12
+ langAlias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13
+ defaultShowLineNumbers: z.ZodOptional<z.ZodBoolean>;
14
+ }, z.core.$strip>>;
15
+ }, z.core.$strip>;
16
+ type MarkdownConfig = z.infer<typeof MarkdownConfigSchema>;
17
+ //#endregion
18
+ //#region src/schemas/heading.d.ts
19
+ declare const HeadingSchema: z.ZodObject<{
20
+ depth: z.ZodNumber;
21
+ text: z.ZodString;
22
+ slug: z.ZodString;
23
+ }, z.core.$strip>;
24
+ type Heading = z.infer<typeof HeadingSchema>;
25
+ //#endregion
26
+ export { MarkdownConfigSchema as i, HeadingSchema as n, MarkdownConfig as r, Heading as t };
27
+ //# sourceMappingURL=heading-Dhvzlay-.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading-Dhvzlay-.d.mts","names":[],"sources":["../src/schemas/markdown-config.ts","../src/schemas/heading.ts"],"mappings":";;;cAIa,oBAAA,EAAoB,CAAA,CAAA,SAAA;;;;;;;;;;;;KAerB,cAAA,GAAiB,CAAA,CAAE,KAAA,QAAa,oBAAA;;;cCf/B,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;KAMd,OAAA,GAAU,CAAA,CAAE,KAAA,QAAa,aAAA"}
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/schemas/frontmatter.d.ts
4
+ declare const BaseFrontmatterSchema: z.ZodObject<{
5
+ title: z.ZodString;
6
+ description: z.ZodString;
7
+ publishedDate: z.ZodCoercedDate<unknown>;
8
+ lastUpdatedOn: z.ZodCoercedDate<unknown>;
9
+ tags: z.ZodArray<z.ZodString>;
10
+ draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
11
+ }, z.core.$loose>;
12
+ type BaseFrontmatter = z.infer<typeof BaseFrontmatterSchema>;
13
+ declare const ProjectFrontmatterSchema: z.ZodObject<{
14
+ title: z.ZodString;
15
+ description: z.ZodString;
16
+ publishedDate: z.ZodCoercedDate<unknown>;
17
+ lastUpdatedOn: z.ZodCoercedDate<unknown>;
18
+ tags: z.ZodArray<z.ZodString>;
19
+ draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
20
+ gitRepo: z.ZodOptional<z.ZodString>;
21
+ links: z.ZodOptional<z.ZodArray<z.ZodObject<{
22
+ url: z.ZodString;
23
+ text: z.ZodString;
24
+ }, z.core.$strip>>>;
25
+ }, z.core.$loose>;
26
+ type ProjectFrontmatter = z.infer<typeof ProjectFrontmatterSchema>;
27
+ declare const BlogFrontmatterSchema: z.ZodObject<{
28
+ title: z.ZodString;
29
+ description: z.ZodString;
30
+ publishedDate: z.ZodCoercedDate<unknown>;
31
+ lastUpdatedOn: z.ZodCoercedDate<unknown>;
32
+ tags: z.ZodArray<z.ZodString>;
33
+ draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
34
+ category: z.ZodOptional<z.ZodString>;
35
+ featured: z.ZodOptional<z.ZodBoolean>;
36
+ coverImage: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$loose>;
38
+ type BlogFrontmatter = z.infer<typeof BlogFrontmatterSchema>;
39
+ //#endregion
40
+ export { ProjectFrontmatter as a, BlogFrontmatterSchema as i, BaseFrontmatterSchema as n, ProjectFrontmatterSchema as o, BlogFrontmatter as r, BaseFrontmatter as t };
41
+ //# sourceMappingURL=index-BQ6B1-qG.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BQ6B1-qG.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"}
@@ -0,0 +1,7 @@
1
+ //#region src/css/builder.d.ts
2
+ declare function buildCss(entryPath: string, config?: {
3
+ minify?: boolean;
4
+ }): string;
5
+ //#endregion
6
+ export { buildCss as t };
7
+ //# sourceMappingURL=index-CeNDTM-y.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CeNDTM-y.d.mts","names":[],"sources":["../src/css/builder.ts"],"mappings":";iBAGgB,QAAA,CAAS,SAAA,UAAmB,MAAA;EAAW,MAAA;AAAA"}
@@ -0,0 +1,15 @@
1
+ import { r as MarkdownConfig, t as Heading } from "./heading-Dhvzlay-.mjs";
2
+
3
+ //#region src/markdown/pipeline.d.ts
4
+ type MarkdownResult = {
5
+ html: string;
6
+ headings: Heading[];
7
+ frontmatter: Record<string, any>;
8
+ };
9
+ declare function processMarkdown(raw: string, config?: MarkdownConfig, preExtracted?: {
10
+ content: string;
11
+ frontmatter: Record<string, unknown>;
12
+ }): Promise<MarkdownResult>;
13
+ //#endregion
14
+ export { processMarkdown as n, MarkdownResult as t };
15
+ //# sourceMappingURL=index-DpRBzO8Q.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DpRBzO8Q.d.mts","names":[],"sources":["../src/markdown/pipeline.ts"],"mappings":";;;KAuBY,cAAA;EACV,IAAA;EACA,QAAA,EAAU,OAAA;EACV,WAAA,EAAa,MAAA;AAAA;AAAA,iBAgGO,eAAA,CACpB,GAAA,UACA,MAAA,GAAS,cAAA,EACT,YAAA;EAAiB,OAAA;EAAiB,WAAA,EAAa,MAAA;AAAA,IAC9C,OAAA,CAAQ,cAAA"}
@@ -0,0 +1,59 @@
1
+ import { n as LoaderResult, r as LoaderType, t as Loader } from "./types-DUsjRE7Y.mjs";
2
+
3
+ //#region src/loaders/json.d.ts
4
+ declare class JsonLoader implements Loader {
5
+ name: string;
6
+ kind: "data";
7
+ extensions: string[];
8
+ load(filePath: string): LoaderResult;
9
+ }
10
+ //#endregion
11
+ //#region src/loaders/jsonc.d.ts
12
+ declare class JsoncLoader implements Loader {
13
+ name: string;
14
+ kind: "data";
15
+ extensions: string[];
16
+ load(filePath: string): LoaderResult;
17
+ }
18
+ //#endregion
19
+ //#region src/loaders/errors.d.ts
20
+ declare class LoaderError extends Error {
21
+ readonly filePath: string;
22
+ readonly format: string;
23
+ readonly line?: number;
24
+ readonly column?: number;
25
+ constructor(message: string, filePath: string, format: string, line?: number, column?: number);
26
+ }
27
+ //#endregion
28
+ //#region src/loaders/markdown.d.ts
29
+ declare class MarkdownLoader implements Loader {
30
+ name: string;
31
+ kind: "markdown";
32
+ extensions: string[];
33
+ load(filePath: string): LoaderResult;
34
+ }
35
+ //#endregion
36
+ //#region src/loaders/toml.d.ts
37
+ declare class TomlLoader implements Loader {
38
+ name: string;
39
+ kind: "data";
40
+ extensions: string[];
41
+ load(filePath: string): LoaderResult;
42
+ }
43
+ //#endregion
44
+ //#region src/loaders/yaml.d.ts
45
+ declare class YamlLoader implements Loader {
46
+ name: string;
47
+ kind: "data";
48
+ extensions: string[];
49
+ load(filePath: string): LoaderResult;
50
+ }
51
+ //#endregion
52
+ //#region src/loaders/index.d.ts
53
+ /** Resolve a loader type string or custom Loader instance. */
54
+ declare function resolveLoader(loaderOrType: LoaderType | Loader): Loader;
55
+ /** Get default include glob patterns for a loader. */
56
+ declare function defaultIncludePatterns(loader: Loader): string[];
57
+ //#endregion
58
+ export { MarkdownLoader as a, JsonLoader as c, TomlLoader as i, resolveLoader as n, LoaderError as o, YamlLoader as r, JsoncLoader as s, defaultIncludePatterns as t };
59
+ //# sourceMappingURL=index-sFCx17CD.d.mts.map