ardo 3.0.0 → 3.0.2
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.
|
@@ -696,7 +696,13 @@ function ardoPlugin(options = {}) {
|
|
|
696
696
|
exclude: ["ardo/ui/styles.css"]
|
|
697
697
|
},
|
|
698
698
|
ssr: {
|
|
699
|
-
noExternal: ["ardo"]
|
|
699
|
+
noExternal: ["ardo"],
|
|
700
|
+
// Workaround: Rolldown (Vite 8) treats all files as UTF-8 text and
|
|
701
|
+
// fails on native .node binaries like fsevents with "stream did not
|
|
702
|
+
// contain valid UTF-8". This is a known Rolldown limitation:
|
|
703
|
+
// https://github.com/rolldown/rolldown/issues/5662
|
|
704
|
+
// Remove once Rolldown handles native modules natively.
|
|
705
|
+
external: ["fsevents"]
|
|
700
706
|
}
|
|
701
707
|
};
|
|
702
708
|
if (githubPages && env.command === "build" && !userConfig.base) {
|
|
@@ -1327,4 +1333,4 @@ export {
|
|
|
1327
1333
|
getPageDataForRoute,
|
|
1328
1334
|
generateSidebar2 as generateSidebar
|
|
1329
1335
|
};
|
|
1330
|
-
//# sourceMappingURL=chunk-
|
|
1336
|
+
//# sourceMappingURL=chunk-7VP5YEX2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vite/plugin.ts","../src/markdown/shiki.ts","../src/vite/routes-plugin.ts","../src/vite/codeblock-plugin.ts","../src/runtime/loader.ts","../src/markdown/pipeline.ts","../src/markdown/toc.ts","../src/markdown/links.ts","../src/runtime/sidebar.ts"],"sourcesContent":["import type { Plugin, UserConfig } from \"vite\"\nimport type { ArdoConfig, ProjectMeta, ResolvedConfig } from \"../config/types\"\nimport type { TypeDocConfig } from \"../typedoc/types\"\nimport { resolveConfig, defaultMarkdownConfig } from \"../config/index\"\nimport { generateApiDocs } from \"../typedoc/generator\"\nimport { reactRouter } from \"@react-router/dev/vite\"\nimport mdx from \"@mdx-js/rollup\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkMdxFrontmatter from \"remark-mdx-frontmatter\"\nimport remarkGfm from \"remark-gfm\"\nimport rehypeShiki from \"@shikijs/rehype\"\nimport { ardoLineTransformer, remarkCodeMeta } from \"../markdown/shiki\"\nimport fs from \"fs/promises\"\nimport fsSync from \"fs\"\nimport path from \"path\"\nimport { execSync } from \"child_process\"\nimport matter from \"gray-matter\"\nimport { ardoRoutesPlugin, type ArdoRoutesPluginOptions } from \"./routes-plugin\"\nimport { ardoCodeBlockPlugin } from \"./codeblock-plugin\"\n\n/**\n * Finds the package root by looking for package.json in parent directories.\n * Returns the path relative to cwd, or undefined if not found.\n */\nfunction findPackageRoot(cwd: string): string | undefined {\n let dir = path.resolve(cwd)\n const root = path.parse(dir).root\n\n while (dir !== root) {\n const parentDir = path.dirname(dir)\n const packageJsonPath = path.join(parentDir, \"package.json\")\n\n if (fsSync.existsSync(packageJsonPath)) {\n // Return relative path from cwd to parent\n return path.relative(cwd, parentDir) || \".\"\n }\n\n dir = parentDir\n }\n\n return undefined\n}\n\n/**\n * Detects the GitHub repository name from git remote URL.\n * Returns the repo name (e.g., 'ardo' from 'github.com/sebastian-software/ardo')\n * or undefined if not a GitHub repo.\n */\nfunction detectGitHubRepoName(cwd: string): string | undefined {\n try {\n const remoteUrl = execSync(\"git remote get-url origin\", {\n cwd,\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim()\n\n // Parse GitHub URL (supports both HTTPS and SSH)\n // https://github.com/user/repo.git\n // git@github.com:user/repo.git\n const match = remoteUrl.match(/github\\.com[/:][\\w-]+\\/([\\w.-]+?)(?:\\.git)?$/)\n return match?.[1]\n } catch {\n return undefined\n }\n}\n\n/**\n * Detects the current short git commit hash.\n */\nfunction detectGitHash(cwd: string): string | undefined {\n try {\n return execSync(\"git rev-parse --short HEAD\", {\n cwd,\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim()\n } catch {\n return undefined\n }\n}\n\n/**\n * Reads project metadata from the nearest package.json.\n */\nfunction readProjectMeta(root: string): ProjectMeta {\n const pkgPath = path.join(root, \"package.json\")\n try {\n const raw = fsSync.readFileSync(pkgPath, \"utf-8\")\n const pkg = JSON.parse(raw)\n\n let repository: string | undefined\n if (typeof pkg.repository === \"string\") {\n repository = pkg.repository\n } else if (pkg.repository?.url) {\n // Normalize git+https://... or git://... URLs\n repository = pkg.repository.url\n .replace(/^git\\+/, \"\")\n .replace(/^git:\\/\\//, \"https://\")\n .replace(/\\.git$/, \"\")\n }\n\n let author: string | undefined\n if (typeof pkg.author === \"string\") {\n author = pkg.author\n } else if (pkg.author?.name) {\n author = pkg.author.name\n }\n\n return {\n name: pkg.name,\n homepage: pkg.homepage,\n repository,\n version: pkg.version,\n author,\n license: pkg.license,\n }\n } catch {\n return {}\n }\n}\n\n/**\n * Recursively copies files from src to dest, overwriting existing files.\n */\nfunction copyRecursive(src: string, dest: string) {\n const stat = fsSync.statSync(src)\n\n if (stat.isDirectory()) {\n if (!fsSync.existsSync(dest)) {\n fsSync.mkdirSync(dest, { recursive: true })\n }\n for (const item of fsSync.readdirSync(src)) {\n copyRecursive(path.join(src, item), path.join(dest, item))\n }\n } else {\n fsSync.copyFileSync(src, dest)\n }\n}\n\n/**\n * Detects the GitHub Pages basename from the git remote URL.\n * Returns `\"/repo-name/\"` if a GitHub repo is detected, otherwise `undefined`.\n *\n * Use this in `react-router.config.ts` to synchronize client-side routing\n * with the Vite `base` path that Ardo auto-detects:\n *\n * ```ts\n * import { detectGitHubBasename } from \"ardo/vite\"\n *\n * export default {\n * ssr: false,\n * prerender: true,\n * basename: detectGitHubBasename(),\n * } satisfies Config\n * ```\n */\nexport function detectGitHubBasename(cwd?: string): string {\n if (process.env.NODE_ENV !== \"production\") {\n return \"/\"\n }\n const repoName = detectGitHubRepoName(cwd || process.cwd())\n return repoName ? `/${repoName}/` : \"/\"\n}\n\nconst VIRTUAL_MODULE_ID = \"virtual:ardo/config\"\nconst RESOLVED_VIRTUAL_MODULE_ID = \"\\0\" + VIRTUAL_MODULE_ID\n\nconst VIRTUAL_SIDEBAR_ID = \"virtual:ardo/sidebar\"\nconst RESOLVED_VIRTUAL_SIDEBAR_ID = \"\\0\" + VIRTUAL_SIDEBAR_ID\n\nconst VIRTUAL_SEARCH_ID = \"virtual:ardo/search-index\"\nconst RESOLVED_VIRTUAL_SEARCH_ID = \"\\0\" + VIRTUAL_SEARCH_ID\n\n// Module-level flags to prevent duplicate operations across plugin instances\n// This is necessary because React Router creates multiple Vite instances\nlet typedocGenerated = false\nlet flattenExecuted = false\n\nexport interface ArdoPluginOptions extends Partial<ArdoConfig> {\n /** Options for the routes generator plugin */\n routes?: ArdoRoutesPluginOptions | false\n /**\n * Auto-detect GitHub repository and set base path for GitHub Pages.\n * When true, automatically sets `base: '/repo-name/'` if deploying to GitHub Pages.\n * @default true\n */\n githubPages?: boolean\n /**\n * Directory where routes are located.\n * @default \"./app/routes\"\n */\n routesDir?: string\n}\n\nexport function ardoPlugin(options: ArdoPluginOptions = {}): Plugin[] {\n let resolvedConfig: ResolvedConfig\n let routesDir: string\n\n // Extract ardo-specific options from the rest (which is ArdoConfig)\n const {\n routes,\n typedoc,\n githubPages = true,\n routesDir: routesDirOption,\n ...pressConfig\n } = options\n\n const mainPlugin: Plugin = {\n name: \"ardo\",\n enforce: \"pre\",\n\n config(userConfig, env): UserConfig {\n const root = userConfig.root || process.cwd()\n routesDir = routesDirOption || path.join(root, \"app\", \"routes\")\n\n const result: UserConfig = {\n define: {\n __BUILD_TIME__: JSON.stringify(new Date().toISOString()),\n },\n optimizeDeps: {\n exclude: [\"ardo/ui/styles.css\"],\n },\n ssr: {\n noExternal: [\"ardo\"],\n // Workaround: Rolldown (Vite 8) treats all files as UTF-8 text and\n // fails on native .node binaries like fsevents with \"stream did not\n // contain valid UTF-8\". This is a known Rolldown limitation:\n // https://github.com/rolldown/rolldown/issues/5662\n // Remove once Rolldown handles native modules natively.\n external: [\"fsevents\"],\n },\n }\n\n // Auto-detect GitHub Pages base path for production builds\n if (githubPages && env.command === \"build\" && !userConfig.base) {\n const repoName = detectGitHubRepoName(root)\n if (repoName) {\n result.base = `/${repoName}/`\n console.log(`[ardo] GitHub Pages detected, using base: ${result.base}`)\n }\n }\n\n return result\n },\n\n async configResolved(config) {\n const root = config.root\n routesDir = routesDirOption || path.join(root, \"app\", \"routes\")\n\n // Auto-detect project metadata from package.json\n const detectedProject = readProjectMeta(root)\n const project: ProjectMeta = { ...detectedProject, ...pressConfig.project }\n\n const defaultConfig: ArdoConfig = {\n title: pressConfig.title ?? \"Ardo\",\n description: pressConfig.description ?? \"Documentation powered by Ardo\",\n }\n\n // For React Router, contentDir is the routes directory\n const configWithRoutes = {\n ...defaultConfig,\n ...pressConfig,\n project,\n srcDir: routesDir,\n }\n\n resolvedConfig = resolveConfig(configWithRoutes, root)\n },\n\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n if (id === VIRTUAL_SIDEBAR_ID) {\n return RESOLVED_VIRTUAL_SIDEBAR_ID\n }\n if (id === VIRTUAL_SEARCH_ID) {\n return RESOLVED_VIRTUAL_SEARCH_ID\n }\n },\n\n async load(id) {\n if (id === RESOLVED_VIRTUAL_MODULE_ID) {\n const clientConfig = {\n title: resolvedConfig.title,\n description: resolvedConfig.description,\n base: resolvedConfig.base,\n lang: resolvedConfig.lang,\n themeConfig: resolvedConfig.themeConfig,\n project: resolvedConfig.project,\n buildTime: new Date().toISOString(),\n buildHash: detectGitHash(resolvedConfig.root),\n }\n return `export default ${JSON.stringify(clientConfig)}`\n }\n\n if (id === RESOLVED_VIRTUAL_SIDEBAR_ID) {\n const sidebar = await generateSidebar(resolvedConfig, routesDir)\n return `export default ${JSON.stringify(sidebar)}`\n }\n\n if (id === RESOLVED_VIRTUAL_SEARCH_ID) {\n const searchIndex = await generateSearchIndex(routesDir)\n return `export default ${JSON.stringify(searchIndex)}`\n }\n },\n\n transform(code, id) {\n // Only process .mdx/.md files inside the routes directory\n if (!/\\.(mdx|md)$/.test(id)) return\n if (!id.startsWith(routesDir)) return\n\n // Skip if the file already exports a meta function\n if (/export\\s+(const|function)\\s+meta\\b/.test(code)) return\n\n // Extract frontmatter values from the compiled MDX export\n const titleMatch = code.match(\n /export\\s+const\\s+frontmatter\\s*=\\s*\\{[^}]*title\\s*:\\s*\"([^\"]*)\"/\n )\n const descMatch = code.match(\n /export\\s+const\\s+frontmatter\\s*=\\s*\\{[^}]*description\\s*:\\s*\"([^\"]*)\"/\n )\n\n const pageTitle = titleMatch?.[1]\n if (!pageTitle) return\n\n const siteTitle = resolvedConfig.title\n const separator = resolvedConfig.titleSeparator\n const fullTitle = `${pageTitle}${separator}${siteTitle}`\n const description = descMatch?.[1]\n\n const metaEntries = [`{ title: ${JSON.stringify(fullTitle)} }`]\n if (description) {\n metaEntries.push(`{ name: \"description\", content: ${JSON.stringify(description)} }`)\n }\n\n return {\n code: `${code}\\nexport const meta = () => [${metaEntries.join(\", \")}];\\n`,\n map: null,\n }\n },\n }\n\n const plugins: Plugin[] = [mainPlugin]\n\n // Add routes plugin unless explicitly disabled\n if (routes !== false) {\n plugins.push(\n ardoRoutesPlugin({\n routesDir: routesDirOption,\n ...routes,\n })\n )\n }\n\n // Add TypeDoc plugin if enabled\n if (typedoc) {\n // Find package root to use as default entry point and tsconfig base\n const packageRoot = findPackageRoot(process.cwd())\n const defaultEntryPoint = packageRoot ? `${packageRoot}/src/index.ts` : \"./src/index.ts\"\n const defaultTsconfig = packageRoot ? `${packageRoot}/tsconfig.json` : \"./tsconfig.json\"\n\n const defaultTypedocConfig: TypeDocConfig = {\n enabled: true,\n entryPoints: [defaultEntryPoint],\n tsconfig: defaultTsconfig,\n out: \"api-reference\",\n excludePrivate: true,\n excludeInternal: true,\n }\n\n const typedocConfig: TypeDocConfig =\n typedoc === true ? defaultTypedocConfig : { ...defaultTypedocConfig, ...typedoc }\n\n const typedocPlugin: Plugin = {\n name: \"ardo:typedoc\",\n\n async buildStart() {\n // Use module-level flag to prevent duplicate generation across plugin instances\n if (typedocGenerated || !typedocConfig.enabled) {\n return\n }\n\n console.log(\"[ardo] Generating API documentation with TypeDoc...\")\n const startTime = Date.now()\n try {\n const outputDir = routesDirOption || \"./app/routes\"\n const docs = await generateApiDocs(typedocConfig, outputDir)\n const duration = Date.now() - startTime\n console.log(`[ardo] Generated ${docs.length} API documentation pages in ${duration}ms`)\n } catch (error) {\n console.warn(\"[ardo] TypeDoc generation failed. API documentation will not be available.\")\n console.warn(\"[ardo] Check your typedoc.entryPoints configuration.\")\n if (error instanceof Error) {\n console.warn(`[ardo] Error: ${error.message}`)\n }\n }\n typedocGenerated = true\n },\n }\n\n plugins.unshift(typedocPlugin)\n }\n\n // Add CodeBlock highlight plugin for .tsx/.jsx files\n plugins.push(ardoCodeBlockPlugin(pressConfig.markdown))\n\n // Add MDX plugin with Ardo's markdown pipeline\n // Apply default theme if user didn't configure one\n const themeConfig = pressConfig.markdown?.theme ?? defaultMarkdownConfig.theme\n const hasThemeObject = themeConfig && typeof themeConfig === \"object\" && \"light\" in themeConfig\n const lineNumbers = pressConfig.markdown?.lineNumbers || false\n\n // Build shiki options with Ardo's custom line transformer\n // Theme defaults are guaranteed by resolveConfig (defaultMarkdownConfig)\n const shikiOptions = hasThemeObject\n ? {\n themes: {\n light: themeConfig.light,\n dark: themeConfig.dark,\n },\n defaultColor: false as const,\n transformers: [ardoLineTransformer({ globalLineNumbers: lineNumbers })],\n }\n : {\n theme: themeConfig as string,\n transformers: [ardoLineTransformer({ globalLineNumbers: lineNumbers })],\n }\n\n const mdxPlugin = mdx({\n include: /\\.(md|mdx)$/,\n remarkPlugins: [\n remarkFrontmatter,\n [remarkMdxFrontmatter, { name: \"frontmatter\" }],\n remarkGfm,\n remarkCodeMeta,\n ],\n rehypePlugins: [[rehypeShiki, shikiOptions]],\n providerImportSource: \"ardo/mdx-provider\",\n })\n plugins.push(mdxPlugin as Plugin)\n\n // Add React Router Framework plugin (includes React plugin internally)\n const reactRouterPlugin = reactRouter()\n const reactRouterPlugins = (\n Array.isArray(reactRouterPlugin) ? reactRouterPlugin : [reactRouterPlugin]\n ).filter((p): p is Plugin => p != null)\n plugins.push(...reactRouterPlugins)\n\n // Add flatten plugin for GitHub Pages (must run after React Router build)\n if (githubPages) {\n let detectedBase: string | undefined\n\n const flattenPlugin: Plugin = {\n name: \"ardo:flatten-github-pages\",\n enforce: \"post\",\n\n configResolved(config) {\n if (config.base && config.base !== \"/\") {\n detectedBase = config.base\n }\n },\n\n closeBundle() {\n if (flattenExecuted || !detectedBase) {\n return\n }\n\n // Strip leading/trailing slashes to get the directory name\n const baseName = detectedBase.replace(/^\\/|\\/$/g, \"\")\n if (!baseName) return\n\n const buildDir = path.join(process.cwd(), \"build\", \"client\")\n const nestedDir = path.join(buildDir, baseName)\n\n if (!fsSync.existsSync(nestedDir)) {\n return\n }\n\n console.log(`[ardo] Flattening build/client/${baseName}/ to build/client/ for GitHub Pages`)\n copyRecursive(nestedDir, buildDir)\n fsSync.rmSync(nestedDir, { recursive: true, force: true })\n console.log(\"[ardo] Build output flattened successfully.\")\n\n flattenExecuted = true\n },\n }\n\n plugins.push(flattenPlugin)\n }\n\n return plugins\n}\n\nasync function generateSidebar(config: ResolvedConfig, routesDir: string) {\n const { themeConfig } = config\n\n if (themeConfig.sidebar && !Array.isArray(themeConfig.sidebar)) {\n return themeConfig.sidebar\n }\n\n if (themeConfig.sidebar && Array.isArray(themeConfig.sidebar) && themeConfig.sidebar.length > 0) {\n return themeConfig.sidebar\n }\n\n try {\n const sidebar = await scanDirectory(routesDir, routesDir)\n return sidebar\n } catch {\n return []\n }\n}\n\nasync function scanDirectory(\n dir: string,\n rootDir: string\n): Promise<Array<{ text: string; link?: string; items?: unknown[] }>> {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n const items: Array<{ text: string; link?: string; items?: unknown[]; order?: number }> = []\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n const relativePath = path.relative(rootDir, fullPath)\n\n if (entry.isDirectory()) {\n const children = await scanDirectory(fullPath, rootDir)\n if (children.length > 0) {\n // Check for index.mdx in the directory\n const indexPath = path.join(fullPath, \"index.mdx\")\n let link: string | undefined\n\n try {\n await fs.access(indexPath)\n link = \"/\" + relativePath.replace(/\\\\/g, \"/\")\n } catch {\n // No index.mdx\n }\n\n items.push({\n text: formatTitle(entry.name),\n link,\n items: children,\n })\n }\n } else if (\n (entry.name.endsWith(\".mdx\") || entry.name.endsWith(\".md\")) &&\n entry.name !== \"index.mdx\" &&\n entry.name !== \"index.md\"\n ) {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const { data: frontmatter } = matter(fileContent)\n\n const ext = entry.name.endsWith(\".mdx\") ? \".mdx\" : \".md\"\n const title = frontmatter.title || formatTitle(entry.name.replace(ext, \"\"))\n const order: number | undefined =\n typeof frontmatter.order === \"number\" ? frontmatter.order : undefined\n\n const link = \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n\n items.push({\n text: title,\n link,\n order,\n })\n }\n }\n\n items.sort((a, b) => {\n if (a.order !== undefined && b.order !== undefined) {\n return a.order - b.order\n }\n if (a.order !== undefined) return -1\n if (b.order !== undefined) return 1\n return a.text.localeCompare(b.text)\n })\n\n return items.map(({ order: _order, ...item }) => item)\n}\n\nfunction formatTitle(name: string): string {\n return name.replace(/[-_]/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\ninterface SearchDoc {\n id: string\n title: string\n content: string\n path: string\n section?: string\n}\n\nasync function generateSearchIndex(routesDir: string): Promise<SearchDoc[]> {\n const docs: SearchDoc[] = []\n\n async function scanForSearch(dir: string, section?: string): Promise<void> {\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Use directory name as section for nested content\n const newSection = section\n ? `${section} > ${formatTitle(entry.name)}`\n : formatTitle(entry.name)\n await scanForSearch(fullPath, newSection)\n } else if (entry.name.endsWith(\".mdx\") || entry.name.endsWith(\".md\")) {\n const relativePath = path.relative(routesDir, fullPath)\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n\n // Extract frontmatter\n const { data: frontmatter, content: rawContent } = matter(fileContent)\n const ext = entry.name.endsWith(\".mdx\") ? \".mdx\" : \".md\"\n const title = frontmatter.title || formatTitle(entry.name.replace(ext, \"\"))\n let content = rawContent\n\n // Clean up content: remove markdown/MDX syntax, keep text\n content = content\n .replace(/```[\\s\\S]*?```/g, \"\") // Remove code blocks\n .replace(/`[^`]+`/g, \"\") // Remove inline code\n .replace(/import\\s+.*?from\\s+['\"].*?['\"]/g, \"\") // Remove imports\n .replace(/<[^>]+>/g, \"\") // Remove JSX tags\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\") // Links to text\n .replace(/[#*_~>]/g, \"\") // Remove markdown symbols\n .replace(/\\n+/g, \" \") // Newlines to spaces\n .replace(/\\s+/g, \" \") // Multiple spaces to single\n .trim()\n .slice(0, 2000) // Limit content size\n\n // Generate path for the route\n const routePath =\n entry.name === \"index.mdx\" || entry.name === \"index.md\"\n ? \"/\" + path.dirname(relativePath).replace(/\\\\/g, \"/\")\n : \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n\n // Skip root index (use \"/\" as path)\n const finalPath = routePath === \"/.\" ? \"/\" : routePath\n\n docs.push({\n id: relativePath,\n title,\n content,\n path: finalPath,\n section,\n })\n }\n }\n } catch (error) {\n console.warn(\n \"[ardo] Failed to scan for search index:\",\n error instanceof Error ? error.message : error\n )\n }\n }\n\n await scanForSearch(routesDir)\n return docs\n}\n\nexport default ardoPlugin\n","import {\n createHighlighter,\n type Highlighter,\n type BundledTheme,\n type ShikiTransformer,\n} from \"shiki\"\nimport type { Root, Element, Text } from \"hast\"\nimport { visit } from \"unist-util-visit\"\nimport type { MarkdownConfig } from \"../config/types\"\n\nexport type ShikiHighlighter = Highlighter\n\n/** Default Ardo themes used when no config is provided */\nconst DEFAULT_THEMES = {\n light: \"github-light-default\" as BundledTheme,\n dark: \"github-dark-default\" as BundledTheme,\n}\n\nlet cachedHighlighter: ShikiHighlighter | undefined\n\n/**\n * Highlights code using Shiki with Ardo's default themes.\n * Creates and caches a highlighter instance for reuse.\n */\nexport async function highlightCode(\n code: string,\n language: string,\n options?: { theme?: MarkdownConfig[\"theme\"] }\n): Promise<string> {\n const themeConfig = options?.theme ?? DEFAULT_THEMES\n\n if (!cachedHighlighter) {\n cachedHighlighter = await createShikiHighlighter({\n theme: themeConfig,\n lineNumbers: false,\n anchor: false,\n toc: { level: [2, 3] },\n })\n }\n\n if (typeof themeConfig === \"string\") {\n return cachedHighlighter.codeToHtml(code, { lang: language, theme: themeConfig })\n }\n\n return cachedHighlighter.codeToHtml(code, {\n lang: language,\n themes: { light: themeConfig.light, dark: themeConfig.dark },\n defaultColor: false,\n })\n}\n\nexport async function createShikiHighlighter(config: MarkdownConfig): Promise<ShikiHighlighter> {\n const themeConfig = config.theme!\n\n const themes: BundledTheme[] =\n typeof themeConfig === \"string\" ? [themeConfig] : [themeConfig.light, themeConfig.dark]\n\n const highlighter = await createHighlighter({\n themes,\n langs: [\n // Web fundamentals\n \"javascript\",\n \"typescript\",\n \"jsx\",\n \"tsx\",\n \"html\",\n \"css\",\n \"scss\",\n\n // Data & config formats\n \"json\",\n \"jsonc\",\n \"yaml\",\n \"toml\",\n \"xml\",\n \"graphql\",\n\n // Markdown & docs\n \"markdown\",\n \"mdx\",\n\n // Shell & DevOps\n \"bash\",\n \"shell\",\n \"dockerfile\",\n\n // General purpose\n \"python\",\n \"rust\",\n \"go\",\n \"sql\",\n \"diff\",\n ],\n })\n\n return highlighter\n}\n\ninterface RehypeShikiOptions {\n highlighter: ShikiHighlighter\n config: MarkdownConfig\n}\n\nexport function rehypeShikiFromHighlighter(options: RehypeShikiOptions) {\n const { highlighter, config } = options\n\n const themeConfig = config.theme!\n\n return function (tree: Root) {\n visit(tree, \"element\", (node: Element, index, parent) => {\n if (\n node.tagName !== \"pre\" ||\n !node.children[0] ||\n (node.children[0] as Element).tagName !== \"code\"\n ) {\n return\n }\n\n const codeNode = node.children[0] as Element\n const className = (codeNode.properties?.className as string[]) || []\n const langClass = className.find((c) => c.startsWith(\"language-\"))\n const lang = langClass ? langClass.replace(\"language-\", \"\") : \"text\"\n\n const codeContent = getTextContent(codeNode)\n\n if (!codeContent.trim()) {\n return\n }\n\n try {\n let html: string\n\n if (typeof themeConfig === \"string\") {\n html = highlighter.codeToHtml(codeContent, {\n lang,\n theme: themeConfig,\n })\n } else {\n html = highlighter.codeToHtml(codeContent, {\n lang,\n themes: {\n light: themeConfig.light,\n dark: themeConfig.dark,\n },\n defaultColor: false,\n })\n }\n\n const metaString = (codeNode.properties?.metastring as string) || \"\"\n const lineNumbers = config.lineNumbers || metaString.includes(\"showLineNumbers\")\n const highlightLines = parseHighlightLines(metaString)\n const title = parseTitle(metaString)\n\n const wrapperHtml = buildCodeBlockHtml(html, {\n lang,\n lineNumbers,\n highlightLines,\n title,\n })\n\n if (parent && typeof index === \"number\") {\n const newNode: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: {\n className: [\"ardo-code-block\"],\n \"data-lang\": lang,\n },\n children: [\n {\n type: \"raw\",\n value: wrapperHtml,\n } as unknown as Element,\n ],\n }\n parent.children[index] = newNode\n }\n } catch {\n // If highlighting fails, leave the node unchanged\n }\n })\n }\n}\n\nfunction getTextContent(node: Element | Text): string {\n if (node.type === \"text\") {\n return node.value\n }\n if (\"children\" in node) {\n return node.children.map((child) => getTextContent(child as Element | Text)).join(\"\")\n }\n return \"\"\n}\n\nfunction parseHighlightLines(meta: string): number[] {\n const match = meta.match(/\\{([\\d,-]+)\\}/)\n if (!match) return []\n\n const ranges = match[1].split(\",\")\n const lines: number[] = []\n\n for (const range of ranges) {\n if (range.includes(\"-\")) {\n const [start, end] = range.split(\"-\").map(Number)\n for (let i = start; i <= end; i++) {\n lines.push(i)\n }\n } else {\n lines.push(Number(range))\n }\n }\n\n return lines\n}\n\nfunction parseTitle(meta: string): string | undefined {\n const match = meta.match(/title=\"([^\"]+)\"/)\n return match ? match[1] : undefined\n}\n\ninterface CodeBlockOptions {\n lang: string\n lineNumbers: boolean\n highlightLines: number[]\n title?: string\n}\n\nfunction buildCodeBlockHtml(shikiHtml: string, options: CodeBlockOptions): string {\n const { lang, lineNumbers, highlightLines, title } = options\n\n let html = \"\"\n\n if (title) {\n html += `<div class=\"ardo-code-title\">${escapeHtml(title)}</div>`\n }\n\n html += `<div class=\"ardo-code-wrapper\" data-lang=\"${lang}\">`\n\n if (lineNumbers || highlightLines.length > 0) {\n const lines = shikiHtml.split(\"\\n\")\n const processedHtml = lines\n .map((line, i) => {\n const lineNum = i + 1\n const isHighlighted = highlightLines.includes(lineNum)\n const classes = [\"ardo-code-line\"]\n if (isHighlighted) classes.push(\"highlighted\")\n\n let prefix = \"\"\n if (lineNumbers) {\n prefix = `<span class=\"ardo-line-number\">${lineNum}</span>`\n }\n\n return `<span class=\"${classes.join(\" \")}\">${prefix}${line}</span>`\n })\n .join(\"\\n\")\n\n html += processedHtml\n } else {\n html += shikiHtml\n }\n\n html += `<button class=\"ardo-copy-button\" data-code=\"${encodeURIComponent(extractCodeFromHtml(shikiHtml))}\">\n <span class=\"ardo-copy-icon\">Copy</span>\n <span class=\"ardo-copied-icon\" style=\"display:none\">Copied!</span>\n </button>`\n\n html += \"</div>\"\n\n return html\n}\n\nfunction extractCodeFromHtml(html: string): string {\n return html\n .replace(/<[^>]+>/g, \"\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/&/g, \"&\")\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n}\n\nfunction escapeHtml(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\")\n}\n\n/**\n * Remark plugin that extracts code fence meta info and stores it as HAST\n * data attributes before MDX compilation can corrupt it.\n *\n * MDX treats `{...}` in code fence meta as JSX expressions, which corrupts\n * both the meta and the code content. This plugin strips the meta and\n * stores parsed info as `data-ardo-*` attributes that survive MDX.\n */\nexport function remarkCodeMeta() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (tree: any) {\n visit(tree, \"code\", (node: { meta?: string | null; data?: Record<string, unknown> }) => {\n if (!node.meta) return\n\n const meta = node.meta\n const data = node.data || (node.data = {})\n const hProperties = (data.hProperties as Record<string, unknown>) || {}\n\n // Preserve meta as metastring property on the <code> HAST element.\n // @shikijs/rehype reads head.properties.metastring and passes it\n // to Shiki as meta.__raw, which ardoLineTransformer reads.\n hProperties.metastring = meta\n data.hProperties = hProperties\n\n // Strip meta from the MDAST node to prevent MDX from\n // misinterpreting {expressions} like {2,4-5} as JSX\n node.meta = null\n })\n }\n}\n\n/**\n * Shiki transformer that adds Ardo-specific line classes, highlighting,\n * line numbers, and title attributes to code blocks.\n *\n * Used with @shikijs/rehype in the MDX pipeline where proper HAST nodes\n * are required (raw HTML nodes cause \"Cannot handle unknown node `raw`\" errors).\n */\ninterface ArdoLineTransformerOptions {\n globalLineNumbers?: boolean\n}\n\nexport function ardoLineTransformer(options: ArdoLineTransformerOptions = {}): ShikiTransformer {\n let highlightLines: number[] = []\n let showLineNumbers = false\n let metaRaw = \"\"\n\n return {\n name: \"ardo:lines\",\n // preprocess runs BEFORE line() hooks, so state is ready for line()\n preprocess(_code, shikiOptions) {\n metaRaw = (shikiOptions.meta?.__raw as string) || \"\"\n highlightLines = parseHighlightLines(metaRaw)\n showLineNumbers = options.globalLineNumbers || metaRaw.includes(\"showLineNumbers\")\n },\n // pre runs AFTER line() — used only for node property modifications\n pre(node) {\n node.properties = node.properties || {}\n const title = parseTitle(metaRaw)\n if (title) {\n node.properties[\"data-title\"] = title\n }\n const labelMatch = metaRaw.match(/\\[([^\\]]+)\\]/)\n if (labelMatch) {\n node.properties[\"data-label\"] = labelMatch[1]\n }\n },\n line(node, line) {\n const currentClass = (node.properties?.class as string) || \"\"\n const classes = currentClass ? currentClass.split(\" \") : []\n classes.push(\"ardo-code-line\")\n\n if (highlightLines.includes(line)) {\n classes.push(\"highlighted\")\n }\n\n node.properties = node.properties || {}\n node.properties.class = classes.join(\" \")\n\n if (showLineNumbers) {\n node.children.unshift({\n type: \"element\",\n tagName: \"span\",\n properties: { class: \"ardo-line-number\" },\n children: [{ type: \"text\", value: String(line) }],\n } as Element)\n }\n },\n }\n}\n","import type { Plugin } from \"vite\"\nimport fs from \"fs/promises\"\nimport fsSync from \"fs\"\nimport path from \"path\"\n\nexport interface ArdoRoutesPluginOptions {\n /** Directory where routes are located (default: \"./app/routes\") */\n routesDir?: string\n}\n\ninterface RouteInfo {\n /** URL path (e.g., \"/guide/getting-started\") */\n path: string\n /** File path relative to app directory (e.g., \"routes/guide/getting-started.mdx\") */\n file: string\n /** True if this is an index route */\n isIndex?: boolean\n}\n\n/**\n * Vite plugin that generates routes.ts for React Router Framework Mode.\n * Scans app/routes for .mdx and .tsx files and generates the route configuration.\n */\nexport function ardoRoutesPlugin(options: ArdoRoutesPluginOptions = {}): Plugin {\n let routesDir: string\n let appDir: string\n let routesFilePath: string\n\n function scanRoutesSync(dir: string, rootDir: string): RouteInfo[] {\n const routes: RouteInfo[] = []\n\n try {\n const entries = fsSync.readdirSync(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Recursively scan subdirectories\n const children = scanRoutesSync(fullPath, rootDir)\n routes.push(...children)\n } else if (\n entry.name.endsWith(\".mdx\") ||\n entry.name.endsWith(\".md\") ||\n entry.name.endsWith(\".tsx\")\n ) {\n // Skip special files\n if (entry.name === \"root.tsx\" || entry.name.startsWith(\"_\")) {\n continue\n }\n\n const relativePath = path.relative(rootDir, fullPath)\n const ext = entry.name.endsWith(\".mdx\")\n ? \".mdx\"\n : entry.name.endsWith(\".md\")\n ? \".md\"\n : \".tsx\"\n const baseName = entry.name.replace(ext, \"\")\n\n // Calculate URL path\n let urlPath: string\n if (baseName === \"index\" || baseName === \"home\") {\n // Index route - use parent directory path\n const parentDir = path.dirname(relativePath)\n urlPath = parentDir === \".\" ? \"/\" : \"/\" + parentDir.replace(/\\\\/g, \"/\")\n } else {\n // Regular route\n urlPath = \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n }\n\n // Handle dynamic segments ($param -> :param)\n urlPath = urlPath.replace(/\\$(\\w+)/g, \":$1\")\n\n routes.push({\n path: urlPath,\n file: \"routes/\" + relativePath.replace(/\\\\/g, \"/\"),\n isIndex: baseName === \"index\" || baseName === \"home\",\n })\n }\n }\n } catch {\n // Directory may not exist yet\n }\n\n return routes\n }\n\n function generateRoutesFile(routes: RouteInfo[]): string {\n // Sort routes: index routes first, then alphabetically\n const sortedRoutes = [...routes].sort((a, b) => {\n if (a.path === \"/\" && b.path !== \"/\") return -1\n if (b.path === \"/\" && a.path !== \"/\") return 1\n if (a.isIndex && !b.isIndex) return -1\n if (b.isIndex && !a.isIndex) return 1\n return a.path.localeCompare(b.path)\n })\n\n const entries = sortedRoutes.map((r) => {\n if (r.path === \"/\") {\n return ` index(\"${r.file}\"),`\n }\n // Remove leading slash for route path\n const routePath = r.path.substring(1)\n return ` route(\"${routePath}\", \"${r.file}\"),`\n })\n\n return `// AUTO-GENERATED by Ardo - Do not edit manually\n\nimport { type RouteConfig, route, index } from \"@react-router/dev/routes\"\n\nexport default [\n${entries.join(\"\\n\")}\n] satisfies RouteConfig\n`\n }\n\n function writeRoutesFileSync(): void {\n const routes = scanRoutesSync(routesDir, routesDir)\n\n // Skip if no routes found (directory might not exist yet)\n if (routes.length === 0) {\n return\n }\n\n const content = generateRoutesFile(routes)\n\n // Only write if content changed\n try {\n const existing = fsSync.readFileSync(routesFilePath, \"utf-8\")\n if (existing === content) {\n return\n }\n } catch {\n // File doesn't exist yet\n }\n\n // Ensure app directory exists\n fsSync.mkdirSync(appDir, { recursive: true })\n fsSync.writeFileSync(routesFilePath, content, \"utf-8\")\n console.log(`[ardo] Generated routes.ts with ${routes.length} routes`)\n }\n\n async function writeRoutesFile(): Promise<void> {\n const routes = scanRoutesSync(routesDir, routesDir)\n\n // Skip if no routes found (directory might not exist yet)\n if (routes.length === 0) {\n return\n }\n\n const content = generateRoutesFile(routes)\n\n // Only write if content changed\n try {\n const existing = await fs.readFile(routesFilePath, \"utf-8\")\n if (existing === content) {\n return\n }\n } catch {\n // File doesn't exist yet\n }\n\n // Ensure app directory exists\n await fs.mkdir(appDir, { recursive: true })\n await fs.writeFile(routesFilePath, content, \"utf-8\")\n }\n\n return {\n name: \"ardo:routes\",\n enforce: \"pre\",\n\n config(userConfig) {\n const root = userConfig.root || process.cwd()\n appDir = path.join(root, \"app\")\n routesDir = options.routesDir || path.join(appDir, \"routes\")\n routesFilePath = path.join(appDir, \"routes.ts\")\n\n // Generate routes synchronously during config phase\n // React Router needs routes.ts to exist before it starts\n try {\n writeRoutesFileSync()\n } catch (err) {\n console.warn(\"[ardo] Could not generate routes.ts in config phase:\", err)\n }\n },\n\n configResolved(config) {\n // Update paths if not set in config\n if (!appDir) {\n appDir = path.join(config.root, \"app\")\n routesDir = options.routesDir || path.join(appDir, \"routes\")\n routesFilePath = path.join(appDir, \"routes.ts\")\n }\n },\n\n async buildStart() {\n // Re-generate routes in buildStart for async support\n await writeRoutesFile()\n },\n\n configureServer(server) {\n // Watch for changes in routes directory\n server.watcher.add(routesDir)\n\n const handleChange = async (changedPath: string) => {\n if (\n changedPath.startsWith(routesDir) &&\n (changedPath.endsWith(\".mdx\") ||\n changedPath.endsWith(\".md\") ||\n changedPath.endsWith(\".tsx\"))\n ) {\n await writeRoutesFile()\n }\n }\n\n server.watcher.on(\"add\", handleChange)\n server.watcher.on(\"unlink\", handleChange)\n },\n }\n}\n","import type { Plugin } from \"vite\"\nimport type { MarkdownConfig } from \"../config/types\"\nimport { highlightCode } from \"../markdown/shiki\"\n\n/**\n * Strips leading/trailing blank lines and removes common leading whitespace.\n * Same logic as the runtime outdent in CodeBlock.tsx.\n */\nfunction outdent(text: string): string {\n const trimmed = text.replace(/^\\n+/, \"\").replace(/\\n\\s*$/, \"\")\n const lines = trimmed.split(\"\\n\")\n\n const indent = lines.reduce((min, line) => {\n if (line.trim().length === 0) return min\n const match = line.match(/^(\\s*)/)\n return match ? Math.min(min, match[1].length) : min\n }, Infinity)\n\n if (indent === 0 || indent === Infinity) return trimmed\n return lines.map((line) => line.slice(indent)).join(\"\\n\")\n}\n\n/**\n * Finds self-closing `<CodeBlock ... />` tags by scanning for balanced\n * quotes and braces. A simple `[^>]` regex fails when prop values contain\n * `>` characters (e.g. `code={'<Tip>Hello</Tip>'}`).\n */\nfunction findSelfClosingCodeBlocks(\n source: string\n): Array<{ fullMatch: string; propsStr: string; index: number }> {\n const results: Array<{ fullMatch: string; propsStr: string; index: number }> = []\n const tag = \"<CodeBlock\"\n let searchFrom = 0\n\n while (true) {\n const start = source.indexOf(tag, searchFrom)\n if (start === -1) break\n\n // Char after tag name must be whitespace (not > or /)\n const afterTag = start + tag.length\n if (afterTag >= source.length || !/\\s/.test(source[afterTag])) {\n searchFrom = afterTag\n continue\n }\n\n // Scan forward, skipping quoted strings and balanced braces\n let i = afterTag\n let depth = 0\n let inSingle = false\n let inDouble = false\n let inTemplate = false\n let found = false\n\n while (i < source.length) {\n const ch = source[i]\n\n // Handle escape sequences inside strings\n if ((inSingle || inDouble || inTemplate) && ch === \"\\\\\") {\n i += 2\n continue\n }\n\n if (inSingle) {\n if (ch === \"'\") inSingle = false\n i++\n continue\n }\n if (inDouble) {\n if (ch === '\"') inDouble = false\n i++\n continue\n }\n if (inTemplate) {\n if (ch === \"`\") inTemplate = false\n i++\n continue\n }\n\n if (ch === \"'\") {\n inSingle = true\n i++\n continue\n }\n if (ch === '\"') {\n inDouble = true\n i++\n continue\n }\n if (ch === \"`\") {\n inTemplate = true\n i++\n continue\n }\n if (ch === \"{\") {\n depth++\n i++\n continue\n }\n if (ch === \"}\") {\n depth--\n i++\n continue\n }\n\n // Look for /> at depth 0\n if (depth === 0 && ch === \"/\" && i + 1 < source.length && source[i + 1] === \">\") {\n const fullMatch = source.substring(start, i + 2)\n const propsStr = source.substring(afterTag, i).trim()\n results.push({ fullMatch, propsStr, index: start })\n found = true\n searchFrom = i + 2\n break\n }\n\n // If we hit > without / at depth 0, this is an opening tag, not self-closing\n if (depth === 0 && ch === \">\") {\n searchFrom = i + 1\n found = true\n break\n }\n\n i++\n }\n\n if (!found) break\n }\n\n return results\n}\n\n/**\n * Vite plugin that pre-highlights CodeBlock components at build time.\n *\n * Runs before the JSX parser, so children can contain arbitrary code\n * (including `<`, `{`, etc.) without causing syntax errors.\n *\n * Supports three patterns:\n * 1. `<CodeBlock code=\"...\" language=\"...\" />` — code prop\n * 2. `<CodeBlock language=\"...\">{\\`...\\`}</CodeBlock>` — template literal children\n * 3. `<CodeBlock language=\"...\">raw code here</CodeBlock>` — plain text children\n *\n * All patterns are rewritten to a self-closing tag with pre-rendered\n * Shiki HTML before the JSX parser ever sees them.\n */\nexport function ardoCodeBlockPlugin(markdownConfig?: MarkdownConfig): Plugin {\n return {\n name: \"ardo:codeblock-highlight\",\n enforce: \"pre\",\n\n async transform(code, id) {\n if (!/\\.[jt]sx$/.test(id)) return\n if (!code.includes(\"CodeBlock\")) return\n if (id.includes(\"node_modules\")) return\n\n let result = code\n let offset = 0\n\n // Pattern 1: Self-closing <CodeBlock code=\"...\" language=\"...\" />\n // Use a scanner instead of regex because [^>] fails when prop values\n // contain > characters (e.g. code={'<Tip>Hello</Tip>'}).\n const propMatches = findSelfClosingCodeBlocks(code)\n\n for (const match of propMatches) {\n const { fullMatch, propsStr } = match\n\n const codeMatch =\n propsStr.match(/\\bcode=\"((?:[^\"\\\\]|\\\\.)*)\"/s) ||\n propsStr.match(/\\bcode=\\{\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*\\}/s) ||\n propsStr.match(/\\bcode=\\{\\s*'((?:[^'\\\\]|\\\\.)*)'\\s*\\}/s)\n if (!codeMatch) continue\n\n const langMatch =\n propsStr.match(/\\blanguage=\"([^\"]*)\"/) ||\n propsStr.match(/\\blanguage=\\{\"([^\"]*)\"\\}/) ||\n propsStr.match(/\\blanguage=\\{'([^']*)'\\}/)\n if (!langMatch) continue\n\n if (propsStr.includes(\"__html\")) continue\n\n const codeContent = codeMatch[1]\n .replace(/\\\\n/g, \"\\n\")\n .replace(/\\\\\"/g, '\"')\n .replace(/\\\\\\\\/g, \"\\\\\")\n const language = langMatch[1]\n\n try {\n const html = await highlightCode(codeContent, language, {\n theme: markdownConfig?.theme,\n })\n\n const escapedHtml = JSON.stringify(html)\n const newPropsStr = `__html={${escapedHtml}} ` + propsStr\n const newFullMatch = fullMatch.replace(propsStr, newPropsStr)\n\n result =\n result.slice(0, match.index + offset) +\n newFullMatch +\n result.slice(match.index + offset + fullMatch.length)\n\n offset += newFullMatch.length - fullMatch.length\n } catch {\n // If highlighting fails, leave unchanged\n }\n }\n\n // Pattern 2+3: <CodeBlock language=\"...\">...children...</CodeBlock>\n // Matches both template literal children {`...`} and raw text children.\n // Since this runs before JSX parsing, raw text with <, {, etc. is fine.\n const childrenRegex = /<CodeBlock\\s+([^>]*?)>([\\s\\S]*?)<\\/CodeBlock>/g\n\n offset = result.length - code.length\n let regexMatch: RegExpExecArray | null\n while ((regexMatch = childrenRegex.exec(code)) !== null) {\n const fullMatch = regexMatch[0]\n const propsStr = regexMatch[1]\n let rawChildren = regexMatch[2]\n\n const langMatch =\n propsStr.match(/\\blanguage=\"([^\"]*)\"/) ||\n propsStr.match(/\\blanguage=\\{\"([^\"]*)\"\\}/) ||\n propsStr.match(/\\blanguage=\\{'([^']*)'\\}/)\n if (!langMatch) continue\n\n if (propsStr.includes(\"__html\")) continue\n\n // Unwrap template literal braces if present: {`...`} → ...\n const templateMatch = rawChildren.match(/^\\s*\\{`([\\s\\S]*)`\\}\\s*$/)\n if (templateMatch) {\n rawChildren = templateMatch[1]\n }\n\n const codeContent = outdent(rawChildren)\n const language = langMatch[1]\n\n try {\n const html = await highlightCode(codeContent, language, {\n theme: markdownConfig?.theme,\n })\n\n const escapedHtml = JSON.stringify(html)\n const escapedCode = JSON.stringify(codeContent)\n const newTag = `<CodeBlock __html={${escapedHtml}} code={${escapedCode}} ${propsStr} />`\n\n result =\n result.slice(0, regexMatch.index + offset) +\n newTag +\n result.slice(regexMatch.index + offset + fullMatch.length)\n\n offset += newTag.length - fullMatch.length\n } catch {\n // If highlighting fails, leave unchanged\n }\n }\n\n if (result !== code) {\n return { code: result, map: null }\n }\n },\n }\n}\n","import fs from \"fs/promises\"\nimport path from \"path\"\nimport type { PageData, PageFrontmatter, TOCItem, ResolvedConfig } from \"../config/types\"\nimport { transformMarkdown } from \"../markdown/pipeline\"\n\nexport interface LoadDocOptions {\n slug: string\n contentDir: string\n config: ResolvedConfig\n}\n\nexport interface LoadDocResult {\n content: string\n frontmatter: PageFrontmatter\n toc: TOCItem[]\n filePath: string\n relativePath: string\n lastUpdated?: number\n}\n\nexport async function loadDoc(options: LoadDocOptions): Promise<LoadDocResult | null> {\n const { slug, contentDir, config } = options\n\n const possiblePaths = [\n path.join(contentDir, `${slug}.md`),\n path.join(contentDir, slug, \"index.md\"),\n ]\n\n let filePath: string | null = null\n let fileContent: string | null = null\n\n for (const tryPath of possiblePaths) {\n try {\n fileContent = await fs.readFile(tryPath, \"utf-8\")\n filePath = tryPath\n break\n } catch {\n continue\n }\n }\n\n if (!filePath || !fileContent) {\n return null\n }\n\n const result = await transformMarkdown(fileContent, config.markdown)\n const relativePath = path.relative(contentDir, filePath)\n\n let lastUpdated: number | undefined\n try {\n const stat = await fs.stat(filePath)\n lastUpdated = stat.mtimeMs\n } catch {\n // Ignore stat errors\n }\n\n return {\n content: result.html,\n frontmatter: result.frontmatter,\n toc: result.toc,\n filePath,\n relativePath,\n lastUpdated,\n }\n}\n\nexport async function loadAllDocs(contentDir: string, config: ResolvedConfig): Promise<PageData[]> {\n const docs: PageData[] = []\n\n async function scanDir(dir: string) {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n await scanDir(fullPath)\n } else if (entry.name.endsWith(\".md\")) {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const result = await transformMarkdown(fileContent, config.markdown)\n const relativePath = path.relative(contentDir, fullPath)\n\n let lastUpdated: number | undefined\n try {\n const stat = await fs.stat(fullPath)\n lastUpdated = stat.mtimeMs\n } catch {\n // Ignore stat errors\n }\n\n docs.push({\n title: result.frontmatter.title || formatTitle(entry.name.replace(/\\.md$/, \"\")),\n description: result.frontmatter.description,\n frontmatter: result.frontmatter,\n content: result.html,\n toc: result.toc,\n filePath: fullPath,\n relativePath,\n lastUpdated,\n })\n }\n }\n }\n\n await scanDir(contentDir)\n return docs\n}\n\nfunction formatTitle(name: string): string {\n return name.replace(/[-_]/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\nexport function getSlugFromPath(relativePath: string): string {\n return relativePath\n .replace(/\\.md$/, \"\")\n .replace(/\\/index$/, \"\")\n .replace(/\\\\/g, \"/\")\n}\n\nexport function getPageDataForRoute(docs: PageData[], slug: string): PageData | undefined {\n return docs.find((doc) => {\n const docSlug = getSlugFromPath(doc.relativePath)\n return docSlug === slug || docSlug === `${slug}/index`\n })\n}\n","import { unified } from \"unified\"\nimport remarkParse from \"remark-parse\"\nimport remarkGfm from \"remark-gfm\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkRehype from \"remark-rehype\"\nimport rehypeStringify from \"rehype-stringify\"\nimport matter from \"gray-matter\"\nimport type { MarkdownConfig, TOCItem, PageFrontmatter } from \"../config/types\"\nimport { remarkExtractToc, type TocExtraction } from \"./toc\"\nimport { createShikiHighlighter, rehypeShikiFromHighlighter, type ShikiHighlighter } from \"./shiki\"\nimport { rehypeLinks } from \"./links\"\n\nexport interface TransformResult {\n html: string\n frontmatter: PageFrontmatter\n toc: TOCItem[]\n}\n\nexport interface TransformOptions {\n basePath?: string\n highlighter?: ShikiHighlighter\n}\n\nexport async function transformMarkdown(\n content: string,\n config: MarkdownConfig,\n options: TransformOptions = {}\n): Promise<TransformResult> {\n const { data: frontmatter, content: markdownContent } = matter(content)\n const { basePath = \"/\", highlighter: providedHighlighter } = options\n\n const tocExtraction: TocExtraction = { toc: [] }\n const highlighter = providedHighlighter ?? (await createShikiHighlighter(config))\n\n const processor = unified()\n .use(remarkParse)\n .use(remarkFrontmatter, [\"yaml\"])\n .use(remarkGfm)\n .use(remarkExtractToc, { tocExtraction, levels: config.toc?.level ?? [2, 3] })\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeShikiFromHighlighter, { highlighter, config })\n .use(rehypeLinks, { basePath })\n .use(rehypeStringify, { allowDangerousHtml: true })\n\n if (config.remarkPlugins) {\n for (const plugin of config.remarkPlugins) {\n processor.use(plugin as Parameters<typeof processor.use>[0])\n }\n }\n\n if (config.rehypePlugins) {\n for (const plugin of config.rehypePlugins) {\n processor.use(plugin as Parameters<typeof processor.use>[0])\n }\n }\n\n const result = await processor.process(markdownContent)\n\n return {\n html: String(result),\n frontmatter: frontmatter as PageFrontmatter,\n toc: tocExtraction.toc,\n }\n}\n\nexport async function transformMarkdownToReact(\n content: string,\n config: MarkdownConfig\n): Promise<TransformResult> {\n return transformMarkdown(content, config)\n}\n","import type { Root, Heading } from \"mdast\"\nimport { visit } from \"unist-util-visit\"\nimport type { TOCItem } from \"../config/types\"\n\nexport interface TocExtraction {\n toc: TOCItem[]\n}\n\ninterface TocOptions {\n tocExtraction: TocExtraction\n levels: [number, number]\n}\n\nexport function remarkExtractToc(options: TocOptions) {\n const { tocExtraction, levels } = options\n const [minLevel, maxLevel] = levels\n\n return function (tree: Root) {\n const headings: Array<{ text: string; level: number; id: string }> = []\n let headingIndex = 0\n\n visit(tree, \"heading\", (node: Heading) => {\n if (node.depth < minLevel || node.depth > maxLevel) {\n return\n }\n\n const text = getHeadingText(node)\n const slug = slugify(text)\n const id = slug || `heading-${headingIndex}`\n headingIndex++\n\n headings.push({\n text,\n level: node.depth,\n id,\n })\n\n // Add id to the heading node for anchor links\n const data = node.data || (node.data = {})\n const hProperties = (data.hProperties || (data.hProperties = {})) as Record<string, string>\n hProperties.id = id\n })\n\n tocExtraction.toc = buildTocTree(headings, minLevel)\n }\n}\n\nfunction getHeadingText(node: Heading): string {\n const textParts: string[] = []\n\n function extractText(child: unknown) {\n if (!child || typeof child !== \"object\") return\n\n const typedChild = child as { type?: string; value?: string; children?: unknown[] }\n\n if (typedChild.type === \"text\") {\n textParts.push(typedChild.value || \"\")\n } else if (typedChild.type === \"inlineCode\") {\n textParts.push(typedChild.value || \"\")\n } else if (Array.isArray(typedChild.children)) {\n typedChild.children.forEach(extractText)\n }\n }\n\n node.children.forEach(extractText)\n return textParts.join(\"\")\n}\n\nfunction slugify(text: string): string {\n return text\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n}\n\nfunction buildTocTree(\n headings: Array<{ text: string; level: number; id: string }>,\n _minLevel: number\n): TOCItem[] {\n const result: TOCItem[] = []\n const stack: Array<{ item: TOCItem; level: number }> = []\n\n for (const heading of headings) {\n const item: TOCItem = {\n id: heading.id,\n text: heading.text,\n level: heading.level,\n }\n\n while (stack.length > 0 && stack[stack.length - 1].level >= heading.level) {\n stack.pop()\n }\n\n if (stack.length === 0) {\n result.push(item)\n } else {\n const parent = stack[stack.length - 1].item\n if (!parent.children) {\n parent.children = []\n }\n parent.children.push(item)\n }\n\n stack.push({ item, level: heading.level })\n }\n\n return result\n}\n\nexport function flattenToc(toc: TOCItem[]): TOCItem[] {\n const result: TOCItem[] = []\n\n function flatten(items: TOCItem[]) {\n for (const item of items) {\n result.push(item)\n if (item.children) {\n flatten(item.children)\n }\n }\n }\n\n flatten(toc)\n return result\n}\n","import { visit } from \"unist-util-visit\"\nimport type { Root, Element } from \"hast\"\n\nexport interface RehypeLinkOptions {\n basePath: string\n}\n\n/**\n * Rehype plugin that rewrites internal links to include the basePath.\n * This is needed for static sites deployed to subpaths (e.g., GitHub Pages).\n */\nexport function rehypeLinks(options: RehypeLinkOptions) {\n const { basePath } = options\n\n // Normalize basePath: ensure it starts with / and doesn't end with /\n const normalizedBase = basePath === \"/\" ? \"\" : basePath.replace(/\\/$/, \"\")\n\n return (tree: Root) => {\n if (!normalizedBase) {\n // No basePath to add\n return\n }\n\n visit(tree, \"element\", (node: Element) => {\n if (node.tagName === \"a\") {\n const href = node.properties?.href\n\n if (typeof href === \"string\") {\n // Only rewrite internal links that start with /\n // Don't rewrite: external URLs, anchors, relative paths, or already prefixed paths\n if (href.startsWith(\"/\") && !href.startsWith(\"//\") && !href.startsWith(normalizedBase)) {\n node.properties = node.properties || {}\n node.properties.href = normalizedBase + href\n }\n }\n }\n })\n }\n}\n","import fs from \"fs/promises\"\nimport type { Dirent } from \"fs\"\nimport path from \"path\"\nimport matter from \"gray-matter\"\nimport type { SidebarItem, ResolvedConfig } from \"../config/types\"\n\nexport interface SidebarGenerationOptions {\n contentDir: string\n basePath: string\n config: ResolvedConfig\n}\n\nexport async function generateSidebar(options: SidebarGenerationOptions): Promise<SidebarItem[]> {\n const { contentDir, basePath, config } = options\n\n const configSidebar = config.themeConfig.sidebar\n\n if (configSidebar) {\n if (Array.isArray(configSidebar) && configSidebar.length > 0) {\n return configSidebar\n }\n if (!Array.isArray(configSidebar)) {\n return []\n }\n }\n\n return await scanDirectoryForSidebar(contentDir, contentDir, basePath)\n}\n\nasync function scanDirectoryForSidebar(\n dir: string,\n rootDir: string,\n _basePath: string\n): Promise<SidebarItem[]> {\n let entries: Dirent[]\n\n try {\n entries = (await fs.readdir(dir, { withFileTypes: true })) as Dirent[]\n } catch {\n return []\n }\n\n interface SidebarItemWithOrder extends SidebarItem {\n order?: number\n }\n\n const items: SidebarItemWithOrder[] = []\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n const relativePath = path.relative(rootDir, fullPath)\n\n if (entry.name.startsWith(\".\") || entry.name.startsWith(\"_\")) {\n continue\n }\n\n if (entry.isDirectory()) {\n const children = await scanDirectoryForSidebar(fullPath, rootDir, _basePath)\n\n if (children.length > 0) {\n const indexPath = path.join(fullPath, \"index.md\")\n let link: string | undefined\n let title = formatTitle(entry.name)\n let order: number | undefined\n\n try {\n const indexContent = await fs.readFile(indexPath, \"utf-8\")\n const { data: frontmatter } = matter(indexContent)\n\n if (frontmatter.title) {\n title = frontmatter.title\n }\n if (typeof frontmatter.order === \"number\") {\n order = frontmatter.order\n }\n\n // Don't include basePath - React Router handles it automatically\n link = normalizePath(relativePath)\n } catch {\n // No index.md file\n }\n\n items.push({\n text: title,\n link,\n collapsed: false,\n items: children,\n order,\n })\n }\n } else if (entry.name.endsWith(\".md\") && entry.name !== \"index.md\") {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const { data: frontmatter } = matter(fileContent)\n\n if (frontmatter.sidebar === false) {\n continue\n }\n\n const title = frontmatter.title || formatTitle(entry.name.replace(/\\.md$/, \"\"))\n const order = typeof frontmatter.order === \"number\" ? frontmatter.order : undefined\n\n // Don't include basePath - React Router handles it automatically\n const link = normalizePath(relativePath.replace(/\\.md$/, \"\"))\n\n items.push({\n text: title,\n link,\n order,\n })\n }\n }\n\n items.sort((a, b) => {\n if (a.order !== undefined && b.order !== undefined) {\n return a.order - b.order\n }\n if (a.order !== undefined) return -1\n if (b.order !== undefined) return 1\n return a.text.localeCompare(b.text)\n })\n\n return items.map(({ order: _order, ...item }) => item)\n}\n\nfunction formatTitle(name: string): string {\n return name\n .replace(/^\\d+-/, \"\")\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\nfunction normalizePath(p: string): string {\n return \"/\" + p.replace(/\\\\/g, \"/\").replace(/^\\/+/, \"\")\n}\n"],"mappings":";;;;;;;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AAC;AAAA,MACH;AAAA,IACF,WAAW,MAAM,KAAK,SAAS,KAAK,KAAK,MAAM,SAAS,YAAY;AAClE,YAAM,cAAc,MAAMF,IAAG,SAAS,UAAU,OAAO;AACvD,YAAM,EAAE,MAAM,YAAY,IAAIE,QAAO,WAAW;AAEhD,UAAI,YAAY,YAAY,OAAO;AACjC;AAAA,MACF;AAEA,YAAM,QAAQ,YAAY,SAASE,aAAY,MAAM,KAAK,QAAQ,SAAS,EAAE,CAAC;AAC9E,YAAM,QAAQ,OAAO,YAAY,UAAU,WAAW,YAAY,QAAQ;AAG1E,YAAM,OAAO,cAAc,aAAa,QAAQ,SAAS,EAAE,CAAC;AAE5D,YAAM,KAAK;AAAA,QACT,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,KAAK,CAAC,GAAG,MAAM;AACnB,QAAI,EAAE,UAAU,UAAa,EAAE,UAAU,QAAW;AAClD,aAAO,EAAE,QAAQ,EAAE;AAAA,IACrB;AACA,QAAI,EAAE,UAAU,OAAW,QAAO;AAClC,QAAI,EAAE,UAAU,OAAW,QAAO;AAClC,WAAO,EAAE,KAAK,cAAc,EAAE,IAAI;AAAA,EACpC,CAAC;AAED,SAAO,MAAM,IAAI,CAAC,EAAE,OAAO,QAAQ,GAAG,KAAK,MAAM,IAAI;AACvD;AAEA,SAASA,aAAY,MAAsB;AACzC,SAAO,KACJ,QAAQ,SAAS,EAAE,EACnB,QAAQ,SAAS,GAAG,EACpB,QAAQ,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC;AAC5C;AAEA,SAAS,cAAc,GAAmB;AACxC,SAAO,MAAM,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,EAAE;AACvD;","names":["fs","fsSync","path","path","fsSync","fs","fs","path","remarkGfm","remarkFrontmatter","matter","visit","visit","matter","remarkFrontmatter","remarkGfm","path","fs","formatTitle","fs","path","matter","generateSidebar","formatTitle"]}
|
package/dist/index.js
CHANGED
package/dist/vite/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vite/plugin.ts","../src/markdown/shiki.ts","../src/vite/routes-plugin.ts","../src/vite/codeblock-plugin.ts","../src/runtime/loader.ts","../src/markdown/pipeline.ts","../src/markdown/toc.ts","../src/markdown/links.ts","../src/runtime/sidebar.ts"],"sourcesContent":["import type { Plugin, UserConfig } from \"vite\"\nimport type { ArdoConfig, ProjectMeta, ResolvedConfig } from \"../config/types\"\nimport type { TypeDocConfig } from \"../typedoc/types\"\nimport { resolveConfig, defaultMarkdownConfig } from \"../config/index\"\nimport { generateApiDocs } from \"../typedoc/generator\"\nimport { reactRouter } from \"@react-router/dev/vite\"\nimport mdx from \"@mdx-js/rollup\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkMdxFrontmatter from \"remark-mdx-frontmatter\"\nimport remarkGfm from \"remark-gfm\"\nimport rehypeShiki from \"@shikijs/rehype\"\nimport { ardoLineTransformer, remarkCodeMeta } from \"../markdown/shiki\"\nimport fs from \"fs/promises\"\nimport fsSync from \"fs\"\nimport path from \"path\"\nimport { execSync } from \"child_process\"\nimport matter from \"gray-matter\"\nimport { ardoRoutesPlugin, type ArdoRoutesPluginOptions } from \"./routes-plugin\"\nimport { ardoCodeBlockPlugin } from \"./codeblock-plugin\"\n\n/**\n * Finds the package root by looking for package.json in parent directories.\n * Returns the path relative to cwd, or undefined if not found.\n */\nfunction findPackageRoot(cwd: string): string | undefined {\n let dir = path.resolve(cwd)\n const root = path.parse(dir).root\n\n while (dir !== root) {\n const parentDir = path.dirname(dir)\n const packageJsonPath = path.join(parentDir, \"package.json\")\n\n if (fsSync.existsSync(packageJsonPath)) {\n // Return relative path from cwd to parent\n return path.relative(cwd, parentDir) || \".\"\n }\n\n dir = parentDir\n }\n\n return undefined\n}\n\n/**\n * Detects the GitHub repository name from git remote URL.\n * Returns the repo name (e.g., 'ardo' from 'github.com/sebastian-software/ardo')\n * or undefined if not a GitHub repo.\n */\nfunction detectGitHubRepoName(cwd: string): string | undefined {\n try {\n const remoteUrl = execSync(\"git remote get-url origin\", {\n cwd,\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim()\n\n // Parse GitHub URL (supports both HTTPS and SSH)\n // https://github.com/user/repo.git\n // git@github.com:user/repo.git\n const match = remoteUrl.match(/github\\.com[/:][\\w-]+\\/([\\w.-]+?)(?:\\.git)?$/)\n return match?.[1]\n } catch {\n return undefined\n }\n}\n\n/**\n * Detects the current short git commit hash.\n */\nfunction detectGitHash(cwd: string): string | undefined {\n try {\n return execSync(\"git rev-parse --short HEAD\", {\n cwd,\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim()\n } catch {\n return undefined\n }\n}\n\n/**\n * Reads project metadata from the nearest package.json.\n */\nfunction readProjectMeta(root: string): ProjectMeta {\n const pkgPath = path.join(root, \"package.json\")\n try {\n const raw = fsSync.readFileSync(pkgPath, \"utf-8\")\n const pkg = JSON.parse(raw)\n\n let repository: string | undefined\n if (typeof pkg.repository === \"string\") {\n repository = pkg.repository\n } else if (pkg.repository?.url) {\n // Normalize git+https://... or git://... URLs\n repository = pkg.repository.url\n .replace(/^git\\+/, \"\")\n .replace(/^git:\\/\\//, \"https://\")\n .replace(/\\.git$/, \"\")\n }\n\n let author: string | undefined\n if (typeof pkg.author === \"string\") {\n author = pkg.author\n } else if (pkg.author?.name) {\n author = pkg.author.name\n }\n\n return {\n name: pkg.name,\n homepage: pkg.homepage,\n repository,\n version: pkg.version,\n author,\n license: pkg.license,\n }\n } catch {\n return {}\n }\n}\n\n/**\n * Recursively copies files from src to dest, overwriting existing files.\n */\nfunction copyRecursive(src: string, dest: string) {\n const stat = fsSync.statSync(src)\n\n if (stat.isDirectory()) {\n if (!fsSync.existsSync(dest)) {\n fsSync.mkdirSync(dest, { recursive: true })\n }\n for (const item of fsSync.readdirSync(src)) {\n copyRecursive(path.join(src, item), path.join(dest, item))\n }\n } else {\n fsSync.copyFileSync(src, dest)\n }\n}\n\n/**\n * Detects the GitHub Pages basename from the git remote URL.\n * Returns `\"/repo-name/\"` if a GitHub repo is detected, otherwise `undefined`.\n *\n * Use this in `react-router.config.ts` to synchronize client-side routing\n * with the Vite `base` path that Ardo auto-detects:\n *\n * ```ts\n * import { detectGitHubBasename } from \"ardo/vite\"\n *\n * export default {\n * ssr: false,\n * prerender: true,\n * basename: detectGitHubBasename(),\n * } satisfies Config\n * ```\n */\nexport function detectGitHubBasename(cwd?: string): string {\n if (process.env.NODE_ENV !== \"production\") {\n return \"/\"\n }\n const repoName = detectGitHubRepoName(cwd || process.cwd())\n return repoName ? `/${repoName}/` : \"/\"\n}\n\nconst VIRTUAL_MODULE_ID = \"virtual:ardo/config\"\nconst RESOLVED_VIRTUAL_MODULE_ID = \"\\0\" + VIRTUAL_MODULE_ID\n\nconst VIRTUAL_SIDEBAR_ID = \"virtual:ardo/sidebar\"\nconst RESOLVED_VIRTUAL_SIDEBAR_ID = \"\\0\" + VIRTUAL_SIDEBAR_ID\n\nconst VIRTUAL_SEARCH_ID = \"virtual:ardo/search-index\"\nconst RESOLVED_VIRTUAL_SEARCH_ID = \"\\0\" + VIRTUAL_SEARCH_ID\n\n// Module-level flags to prevent duplicate operations across plugin instances\n// This is necessary because React Router creates multiple Vite instances\nlet typedocGenerated = false\nlet flattenExecuted = false\n\nexport interface ArdoPluginOptions extends Partial<ArdoConfig> {\n /** Options for the routes generator plugin */\n routes?: ArdoRoutesPluginOptions | false\n /**\n * Auto-detect GitHub repository and set base path for GitHub Pages.\n * When true, automatically sets `base: '/repo-name/'` if deploying to GitHub Pages.\n * @default true\n */\n githubPages?: boolean\n /**\n * Directory where routes are located.\n * @default \"./app/routes\"\n */\n routesDir?: string\n}\n\nexport function ardoPlugin(options: ArdoPluginOptions = {}): Plugin[] {\n let resolvedConfig: ResolvedConfig\n let routesDir: string\n\n // Extract ardo-specific options from the rest (which is ArdoConfig)\n const {\n routes,\n typedoc,\n githubPages = true,\n routesDir: routesDirOption,\n ...pressConfig\n } = options\n\n const mainPlugin: Plugin = {\n name: \"ardo\",\n enforce: \"pre\",\n\n config(userConfig, env): UserConfig {\n const root = userConfig.root || process.cwd()\n routesDir = routesDirOption || path.join(root, \"app\", \"routes\")\n\n const result: UserConfig = {\n define: {\n __BUILD_TIME__: JSON.stringify(new Date().toISOString()),\n },\n optimizeDeps: {\n exclude: [\"ardo/ui/styles.css\"],\n },\n ssr: {\n noExternal: [\"ardo\"],\n },\n }\n\n // Auto-detect GitHub Pages base path for production builds\n if (githubPages && env.command === \"build\" && !userConfig.base) {\n const repoName = detectGitHubRepoName(root)\n if (repoName) {\n result.base = `/${repoName}/`\n console.log(`[ardo] GitHub Pages detected, using base: ${result.base}`)\n }\n }\n\n return result\n },\n\n async configResolved(config) {\n const root = config.root\n routesDir = routesDirOption || path.join(root, \"app\", \"routes\")\n\n // Auto-detect project metadata from package.json\n const detectedProject = readProjectMeta(root)\n const project: ProjectMeta = { ...detectedProject, ...pressConfig.project }\n\n const defaultConfig: ArdoConfig = {\n title: pressConfig.title ?? \"Ardo\",\n description: pressConfig.description ?? \"Documentation powered by Ardo\",\n }\n\n // For React Router, contentDir is the routes directory\n const configWithRoutes = {\n ...defaultConfig,\n ...pressConfig,\n project,\n srcDir: routesDir,\n }\n\n resolvedConfig = resolveConfig(configWithRoutes, root)\n },\n\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n if (id === VIRTUAL_SIDEBAR_ID) {\n return RESOLVED_VIRTUAL_SIDEBAR_ID\n }\n if (id === VIRTUAL_SEARCH_ID) {\n return RESOLVED_VIRTUAL_SEARCH_ID\n }\n },\n\n async load(id) {\n if (id === RESOLVED_VIRTUAL_MODULE_ID) {\n const clientConfig = {\n title: resolvedConfig.title,\n description: resolvedConfig.description,\n base: resolvedConfig.base,\n lang: resolvedConfig.lang,\n themeConfig: resolvedConfig.themeConfig,\n project: resolvedConfig.project,\n buildTime: new Date().toISOString(),\n buildHash: detectGitHash(resolvedConfig.root),\n }\n return `export default ${JSON.stringify(clientConfig)}`\n }\n\n if (id === RESOLVED_VIRTUAL_SIDEBAR_ID) {\n const sidebar = await generateSidebar(resolvedConfig, routesDir)\n return `export default ${JSON.stringify(sidebar)}`\n }\n\n if (id === RESOLVED_VIRTUAL_SEARCH_ID) {\n const searchIndex = await generateSearchIndex(routesDir)\n return `export default ${JSON.stringify(searchIndex)}`\n }\n },\n\n transform(code, id) {\n // Only process .mdx/.md files inside the routes directory\n if (!/\\.(mdx|md)$/.test(id)) return\n if (!id.startsWith(routesDir)) return\n\n // Skip if the file already exports a meta function\n if (/export\\s+(const|function)\\s+meta\\b/.test(code)) return\n\n // Extract frontmatter values from the compiled MDX export\n const titleMatch = code.match(\n /export\\s+const\\s+frontmatter\\s*=\\s*\\{[^}]*title\\s*:\\s*\"([^\"]*)\"/\n )\n const descMatch = code.match(\n /export\\s+const\\s+frontmatter\\s*=\\s*\\{[^}]*description\\s*:\\s*\"([^\"]*)\"/\n )\n\n const pageTitle = titleMatch?.[1]\n if (!pageTitle) return\n\n const siteTitle = resolvedConfig.title\n const separator = resolvedConfig.titleSeparator\n const fullTitle = `${pageTitle}${separator}${siteTitle}`\n const description = descMatch?.[1]\n\n const metaEntries = [`{ title: ${JSON.stringify(fullTitle)} }`]\n if (description) {\n metaEntries.push(`{ name: \"description\", content: ${JSON.stringify(description)} }`)\n }\n\n return {\n code: `${code}\\nexport const meta = () => [${metaEntries.join(\", \")}];\\n`,\n map: null,\n }\n },\n }\n\n const plugins: Plugin[] = [mainPlugin]\n\n // Add routes plugin unless explicitly disabled\n if (routes !== false) {\n plugins.push(\n ardoRoutesPlugin({\n routesDir: routesDirOption,\n ...routes,\n })\n )\n }\n\n // Add TypeDoc plugin if enabled\n if (typedoc) {\n // Find package root to use as default entry point and tsconfig base\n const packageRoot = findPackageRoot(process.cwd())\n const defaultEntryPoint = packageRoot ? `${packageRoot}/src/index.ts` : \"./src/index.ts\"\n const defaultTsconfig = packageRoot ? `${packageRoot}/tsconfig.json` : \"./tsconfig.json\"\n\n const defaultTypedocConfig: TypeDocConfig = {\n enabled: true,\n entryPoints: [defaultEntryPoint],\n tsconfig: defaultTsconfig,\n out: \"api-reference\",\n excludePrivate: true,\n excludeInternal: true,\n }\n\n const typedocConfig: TypeDocConfig =\n typedoc === true ? defaultTypedocConfig : { ...defaultTypedocConfig, ...typedoc }\n\n const typedocPlugin: Plugin = {\n name: \"ardo:typedoc\",\n\n async buildStart() {\n // Use module-level flag to prevent duplicate generation across plugin instances\n if (typedocGenerated || !typedocConfig.enabled) {\n return\n }\n\n console.log(\"[ardo] Generating API documentation with TypeDoc...\")\n const startTime = Date.now()\n try {\n const outputDir = routesDirOption || \"./app/routes\"\n const docs = await generateApiDocs(typedocConfig, outputDir)\n const duration = Date.now() - startTime\n console.log(`[ardo] Generated ${docs.length} API documentation pages in ${duration}ms`)\n } catch (error) {\n console.warn(\"[ardo] TypeDoc generation failed. API documentation will not be available.\")\n console.warn(\"[ardo] Check your typedoc.entryPoints configuration.\")\n if (error instanceof Error) {\n console.warn(`[ardo] Error: ${error.message}`)\n }\n }\n typedocGenerated = true\n },\n }\n\n plugins.unshift(typedocPlugin)\n }\n\n // Add CodeBlock highlight plugin for .tsx/.jsx files\n plugins.push(ardoCodeBlockPlugin(pressConfig.markdown))\n\n // Add MDX plugin with Ardo's markdown pipeline\n // Apply default theme if user didn't configure one\n const themeConfig = pressConfig.markdown?.theme ?? defaultMarkdownConfig.theme\n const hasThemeObject = themeConfig && typeof themeConfig === \"object\" && \"light\" in themeConfig\n const lineNumbers = pressConfig.markdown?.lineNumbers || false\n\n // Build shiki options with Ardo's custom line transformer\n // Theme defaults are guaranteed by resolveConfig (defaultMarkdownConfig)\n const shikiOptions = hasThemeObject\n ? {\n themes: {\n light: themeConfig.light,\n dark: themeConfig.dark,\n },\n defaultColor: false as const,\n transformers: [ardoLineTransformer({ globalLineNumbers: lineNumbers })],\n }\n : {\n theme: themeConfig as string,\n transformers: [ardoLineTransformer({ globalLineNumbers: lineNumbers })],\n }\n\n const mdxPlugin = mdx({\n include: /\\.(md|mdx)$/,\n remarkPlugins: [\n remarkFrontmatter,\n [remarkMdxFrontmatter, { name: \"frontmatter\" }],\n remarkGfm,\n remarkCodeMeta,\n ],\n rehypePlugins: [[rehypeShiki, shikiOptions]],\n providerImportSource: \"ardo/mdx-provider\",\n })\n plugins.push(mdxPlugin as Plugin)\n\n // Add React Router Framework plugin (includes React plugin internally)\n const reactRouterPlugin = reactRouter()\n const reactRouterPlugins = (\n Array.isArray(reactRouterPlugin) ? reactRouterPlugin : [reactRouterPlugin]\n ).filter((p): p is Plugin => p != null)\n plugins.push(...reactRouterPlugins)\n\n // Add flatten plugin for GitHub Pages (must run after React Router build)\n if (githubPages) {\n let detectedBase: string | undefined\n\n const flattenPlugin: Plugin = {\n name: \"ardo:flatten-github-pages\",\n enforce: \"post\",\n\n configResolved(config) {\n if (config.base && config.base !== \"/\") {\n detectedBase = config.base\n }\n },\n\n closeBundle() {\n if (flattenExecuted || !detectedBase) {\n return\n }\n\n // Strip leading/trailing slashes to get the directory name\n const baseName = detectedBase.replace(/^\\/|\\/$/g, \"\")\n if (!baseName) return\n\n const buildDir = path.join(process.cwd(), \"build\", \"client\")\n const nestedDir = path.join(buildDir, baseName)\n\n if (!fsSync.existsSync(nestedDir)) {\n return\n }\n\n console.log(`[ardo] Flattening build/client/${baseName}/ to build/client/ for GitHub Pages`)\n copyRecursive(nestedDir, buildDir)\n fsSync.rmSync(nestedDir, { recursive: true, force: true })\n console.log(\"[ardo] Build output flattened successfully.\")\n\n flattenExecuted = true\n },\n }\n\n plugins.push(flattenPlugin)\n }\n\n return plugins\n}\n\nasync function generateSidebar(config: ResolvedConfig, routesDir: string) {\n const { themeConfig } = config\n\n if (themeConfig.sidebar && !Array.isArray(themeConfig.sidebar)) {\n return themeConfig.sidebar\n }\n\n if (themeConfig.sidebar && Array.isArray(themeConfig.sidebar) && themeConfig.sidebar.length > 0) {\n return themeConfig.sidebar\n }\n\n try {\n const sidebar = await scanDirectory(routesDir, routesDir)\n return sidebar\n } catch {\n return []\n }\n}\n\nasync function scanDirectory(\n dir: string,\n rootDir: string\n): Promise<Array<{ text: string; link?: string; items?: unknown[] }>> {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n const items: Array<{ text: string; link?: string; items?: unknown[]; order?: number }> = []\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n const relativePath = path.relative(rootDir, fullPath)\n\n if (entry.isDirectory()) {\n const children = await scanDirectory(fullPath, rootDir)\n if (children.length > 0) {\n // Check for index.mdx in the directory\n const indexPath = path.join(fullPath, \"index.mdx\")\n let link: string | undefined\n\n try {\n await fs.access(indexPath)\n link = \"/\" + relativePath.replace(/\\\\/g, \"/\")\n } catch {\n // No index.mdx\n }\n\n items.push({\n text: formatTitle(entry.name),\n link,\n items: children,\n })\n }\n } else if (\n (entry.name.endsWith(\".mdx\") || entry.name.endsWith(\".md\")) &&\n entry.name !== \"index.mdx\" &&\n entry.name !== \"index.md\"\n ) {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const { data: frontmatter } = matter(fileContent)\n\n const ext = entry.name.endsWith(\".mdx\") ? \".mdx\" : \".md\"\n const title = frontmatter.title || formatTitle(entry.name.replace(ext, \"\"))\n const order: number | undefined =\n typeof frontmatter.order === \"number\" ? frontmatter.order : undefined\n\n const link = \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n\n items.push({\n text: title,\n link,\n order,\n })\n }\n }\n\n items.sort((a, b) => {\n if (a.order !== undefined && b.order !== undefined) {\n return a.order - b.order\n }\n if (a.order !== undefined) return -1\n if (b.order !== undefined) return 1\n return a.text.localeCompare(b.text)\n })\n\n return items.map(({ order: _order, ...item }) => item)\n}\n\nfunction formatTitle(name: string): string {\n return name.replace(/[-_]/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\ninterface SearchDoc {\n id: string\n title: string\n content: string\n path: string\n section?: string\n}\n\nasync function generateSearchIndex(routesDir: string): Promise<SearchDoc[]> {\n const docs: SearchDoc[] = []\n\n async function scanForSearch(dir: string, section?: string): Promise<void> {\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Use directory name as section for nested content\n const newSection = section\n ? `${section} > ${formatTitle(entry.name)}`\n : formatTitle(entry.name)\n await scanForSearch(fullPath, newSection)\n } else if (entry.name.endsWith(\".mdx\") || entry.name.endsWith(\".md\")) {\n const relativePath = path.relative(routesDir, fullPath)\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n\n // Extract frontmatter\n const { data: frontmatter, content: rawContent } = matter(fileContent)\n const ext = entry.name.endsWith(\".mdx\") ? \".mdx\" : \".md\"\n const title = frontmatter.title || formatTitle(entry.name.replace(ext, \"\"))\n let content = rawContent\n\n // Clean up content: remove markdown/MDX syntax, keep text\n content = content\n .replace(/```[\\s\\S]*?```/g, \"\") // Remove code blocks\n .replace(/`[^`]+`/g, \"\") // Remove inline code\n .replace(/import\\s+.*?from\\s+['\"].*?['\"]/g, \"\") // Remove imports\n .replace(/<[^>]+>/g, \"\") // Remove JSX tags\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\") // Links to text\n .replace(/[#*_~>]/g, \"\") // Remove markdown symbols\n .replace(/\\n+/g, \" \") // Newlines to spaces\n .replace(/\\s+/g, \" \") // Multiple spaces to single\n .trim()\n .slice(0, 2000) // Limit content size\n\n // Generate path for the route\n const routePath =\n entry.name === \"index.mdx\" || entry.name === \"index.md\"\n ? \"/\" + path.dirname(relativePath).replace(/\\\\/g, \"/\")\n : \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n\n // Skip root index (use \"/\" as path)\n const finalPath = routePath === \"/.\" ? \"/\" : routePath\n\n docs.push({\n id: relativePath,\n title,\n content,\n path: finalPath,\n section,\n })\n }\n }\n } catch (error) {\n console.warn(\n \"[ardo] Failed to scan for search index:\",\n error instanceof Error ? error.message : error\n )\n }\n }\n\n await scanForSearch(routesDir)\n return docs\n}\n\nexport default ardoPlugin\n","import {\n createHighlighter,\n type Highlighter,\n type BundledTheme,\n type ShikiTransformer,\n} from \"shiki\"\nimport type { Root, Element, Text } from \"hast\"\nimport { visit } from \"unist-util-visit\"\nimport type { MarkdownConfig } from \"../config/types\"\n\nexport type ShikiHighlighter = Highlighter\n\n/** Default Ardo themes used when no config is provided */\nconst DEFAULT_THEMES = {\n light: \"github-light-default\" as BundledTheme,\n dark: \"github-dark-default\" as BundledTheme,\n}\n\nlet cachedHighlighter: ShikiHighlighter | undefined\n\n/**\n * Highlights code using Shiki with Ardo's default themes.\n * Creates and caches a highlighter instance for reuse.\n */\nexport async function highlightCode(\n code: string,\n language: string,\n options?: { theme?: MarkdownConfig[\"theme\"] }\n): Promise<string> {\n const themeConfig = options?.theme ?? DEFAULT_THEMES\n\n if (!cachedHighlighter) {\n cachedHighlighter = await createShikiHighlighter({\n theme: themeConfig,\n lineNumbers: false,\n anchor: false,\n toc: { level: [2, 3] },\n })\n }\n\n if (typeof themeConfig === \"string\") {\n return cachedHighlighter.codeToHtml(code, { lang: language, theme: themeConfig })\n }\n\n return cachedHighlighter.codeToHtml(code, {\n lang: language,\n themes: { light: themeConfig.light, dark: themeConfig.dark },\n defaultColor: false,\n })\n}\n\nexport async function createShikiHighlighter(config: MarkdownConfig): Promise<ShikiHighlighter> {\n const themeConfig = config.theme!\n\n const themes: BundledTheme[] =\n typeof themeConfig === \"string\" ? [themeConfig] : [themeConfig.light, themeConfig.dark]\n\n const highlighter = await createHighlighter({\n themes,\n langs: [\n // Web fundamentals\n \"javascript\",\n \"typescript\",\n \"jsx\",\n \"tsx\",\n \"html\",\n \"css\",\n \"scss\",\n\n // Data & config formats\n \"json\",\n \"jsonc\",\n \"yaml\",\n \"toml\",\n \"xml\",\n \"graphql\",\n\n // Markdown & docs\n \"markdown\",\n \"mdx\",\n\n // Shell & DevOps\n \"bash\",\n \"shell\",\n \"dockerfile\",\n\n // General purpose\n \"python\",\n \"rust\",\n \"go\",\n \"sql\",\n \"diff\",\n ],\n })\n\n return highlighter\n}\n\ninterface RehypeShikiOptions {\n highlighter: ShikiHighlighter\n config: MarkdownConfig\n}\n\nexport function rehypeShikiFromHighlighter(options: RehypeShikiOptions) {\n const { highlighter, config } = options\n\n const themeConfig = config.theme!\n\n return function (tree: Root) {\n visit(tree, \"element\", (node: Element, index, parent) => {\n if (\n node.tagName !== \"pre\" ||\n !node.children[0] ||\n (node.children[0] as Element).tagName !== \"code\"\n ) {\n return\n }\n\n const codeNode = node.children[0] as Element\n const className = (codeNode.properties?.className as string[]) || []\n const langClass = className.find((c) => c.startsWith(\"language-\"))\n const lang = langClass ? langClass.replace(\"language-\", \"\") : \"text\"\n\n const codeContent = getTextContent(codeNode)\n\n if (!codeContent.trim()) {\n return\n }\n\n try {\n let html: string\n\n if (typeof themeConfig === \"string\") {\n html = highlighter.codeToHtml(codeContent, {\n lang,\n theme: themeConfig,\n })\n } else {\n html = highlighter.codeToHtml(codeContent, {\n lang,\n themes: {\n light: themeConfig.light,\n dark: themeConfig.dark,\n },\n defaultColor: false,\n })\n }\n\n const metaString = (codeNode.properties?.metastring as string) || \"\"\n const lineNumbers = config.lineNumbers || metaString.includes(\"showLineNumbers\")\n const highlightLines = parseHighlightLines(metaString)\n const title = parseTitle(metaString)\n\n const wrapperHtml = buildCodeBlockHtml(html, {\n lang,\n lineNumbers,\n highlightLines,\n title,\n })\n\n if (parent && typeof index === \"number\") {\n const newNode: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: {\n className: [\"ardo-code-block\"],\n \"data-lang\": lang,\n },\n children: [\n {\n type: \"raw\",\n value: wrapperHtml,\n } as unknown as Element,\n ],\n }\n parent.children[index] = newNode\n }\n } catch {\n // If highlighting fails, leave the node unchanged\n }\n })\n }\n}\n\nfunction getTextContent(node: Element | Text): string {\n if (node.type === \"text\") {\n return node.value\n }\n if (\"children\" in node) {\n return node.children.map((child) => getTextContent(child as Element | Text)).join(\"\")\n }\n return \"\"\n}\n\nfunction parseHighlightLines(meta: string): number[] {\n const match = meta.match(/\\{([\\d,-]+)\\}/)\n if (!match) return []\n\n const ranges = match[1].split(\",\")\n const lines: number[] = []\n\n for (const range of ranges) {\n if (range.includes(\"-\")) {\n const [start, end] = range.split(\"-\").map(Number)\n for (let i = start; i <= end; i++) {\n lines.push(i)\n }\n } else {\n lines.push(Number(range))\n }\n }\n\n return lines\n}\n\nfunction parseTitle(meta: string): string | undefined {\n const match = meta.match(/title=\"([^\"]+)\"/)\n return match ? match[1] : undefined\n}\n\ninterface CodeBlockOptions {\n lang: string\n lineNumbers: boolean\n highlightLines: number[]\n title?: string\n}\n\nfunction buildCodeBlockHtml(shikiHtml: string, options: CodeBlockOptions): string {\n const { lang, lineNumbers, highlightLines, title } = options\n\n let html = \"\"\n\n if (title) {\n html += `<div class=\"ardo-code-title\">${escapeHtml(title)}</div>`\n }\n\n html += `<div class=\"ardo-code-wrapper\" data-lang=\"${lang}\">`\n\n if (lineNumbers || highlightLines.length > 0) {\n const lines = shikiHtml.split(\"\\n\")\n const processedHtml = lines\n .map((line, i) => {\n const lineNum = i + 1\n const isHighlighted = highlightLines.includes(lineNum)\n const classes = [\"ardo-code-line\"]\n if (isHighlighted) classes.push(\"highlighted\")\n\n let prefix = \"\"\n if (lineNumbers) {\n prefix = `<span class=\"ardo-line-number\">${lineNum}</span>`\n }\n\n return `<span class=\"${classes.join(\" \")}\">${prefix}${line}</span>`\n })\n .join(\"\\n\")\n\n html += processedHtml\n } else {\n html += shikiHtml\n }\n\n html += `<button class=\"ardo-copy-button\" data-code=\"${encodeURIComponent(extractCodeFromHtml(shikiHtml))}\">\n <span class=\"ardo-copy-icon\">Copy</span>\n <span class=\"ardo-copied-icon\" style=\"display:none\">Copied!</span>\n </button>`\n\n html += \"</div>\"\n\n return html\n}\n\nfunction extractCodeFromHtml(html: string): string {\n return html\n .replace(/<[^>]+>/g, \"\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/&/g, \"&\")\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n}\n\nfunction escapeHtml(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\")\n}\n\n/**\n * Remark plugin that extracts code fence meta info and stores it as HAST\n * data attributes before MDX compilation can corrupt it.\n *\n * MDX treats `{...}` in code fence meta as JSX expressions, which corrupts\n * both the meta and the code content. This plugin strips the meta and\n * stores parsed info as `data-ardo-*` attributes that survive MDX.\n */\nexport function remarkCodeMeta() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (tree: any) {\n visit(tree, \"code\", (node: { meta?: string | null; data?: Record<string, unknown> }) => {\n if (!node.meta) return\n\n const meta = node.meta\n const data = node.data || (node.data = {})\n const hProperties = (data.hProperties as Record<string, unknown>) || {}\n\n // Preserve meta as metastring property on the <code> HAST element.\n // @shikijs/rehype reads head.properties.metastring and passes it\n // to Shiki as meta.__raw, which ardoLineTransformer reads.\n hProperties.metastring = meta\n data.hProperties = hProperties\n\n // Strip meta from the MDAST node to prevent MDX from\n // misinterpreting {expressions} like {2,4-5} as JSX\n node.meta = null\n })\n }\n}\n\n/**\n * Shiki transformer that adds Ardo-specific line classes, highlighting,\n * line numbers, and title attributes to code blocks.\n *\n * Used with @shikijs/rehype in the MDX pipeline where proper HAST nodes\n * are required (raw HTML nodes cause \"Cannot handle unknown node `raw`\" errors).\n */\ninterface ArdoLineTransformerOptions {\n globalLineNumbers?: boolean\n}\n\nexport function ardoLineTransformer(options: ArdoLineTransformerOptions = {}): ShikiTransformer {\n let highlightLines: number[] = []\n let showLineNumbers = false\n let metaRaw = \"\"\n\n return {\n name: \"ardo:lines\",\n // preprocess runs BEFORE line() hooks, so state is ready for line()\n preprocess(_code, shikiOptions) {\n metaRaw = (shikiOptions.meta?.__raw as string) || \"\"\n highlightLines = parseHighlightLines(metaRaw)\n showLineNumbers = options.globalLineNumbers || metaRaw.includes(\"showLineNumbers\")\n },\n // pre runs AFTER line() — used only for node property modifications\n pre(node) {\n node.properties = node.properties || {}\n const title = parseTitle(metaRaw)\n if (title) {\n node.properties[\"data-title\"] = title\n }\n const labelMatch = metaRaw.match(/\\[([^\\]]+)\\]/)\n if (labelMatch) {\n node.properties[\"data-label\"] = labelMatch[1]\n }\n },\n line(node, line) {\n const currentClass = (node.properties?.class as string) || \"\"\n const classes = currentClass ? currentClass.split(\" \") : []\n classes.push(\"ardo-code-line\")\n\n if (highlightLines.includes(line)) {\n classes.push(\"highlighted\")\n }\n\n node.properties = node.properties || {}\n node.properties.class = classes.join(\" \")\n\n if (showLineNumbers) {\n node.children.unshift({\n type: \"element\",\n tagName: \"span\",\n properties: { class: \"ardo-line-number\" },\n children: [{ type: \"text\", value: String(line) }],\n } as Element)\n }\n },\n }\n}\n","import type { Plugin } from \"vite\"\nimport fs from \"fs/promises\"\nimport fsSync from \"fs\"\nimport path from \"path\"\n\nexport interface ArdoRoutesPluginOptions {\n /** Directory where routes are located (default: \"./app/routes\") */\n routesDir?: string\n}\n\ninterface RouteInfo {\n /** URL path (e.g., \"/guide/getting-started\") */\n path: string\n /** File path relative to app directory (e.g., \"routes/guide/getting-started.mdx\") */\n file: string\n /** True if this is an index route */\n isIndex?: boolean\n}\n\n/**\n * Vite plugin that generates routes.ts for React Router Framework Mode.\n * Scans app/routes for .mdx and .tsx files and generates the route configuration.\n */\nexport function ardoRoutesPlugin(options: ArdoRoutesPluginOptions = {}): Plugin {\n let routesDir: string\n let appDir: string\n let routesFilePath: string\n\n function scanRoutesSync(dir: string, rootDir: string): RouteInfo[] {\n const routes: RouteInfo[] = []\n\n try {\n const entries = fsSync.readdirSync(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Recursively scan subdirectories\n const children = scanRoutesSync(fullPath, rootDir)\n routes.push(...children)\n } else if (\n entry.name.endsWith(\".mdx\") ||\n entry.name.endsWith(\".md\") ||\n entry.name.endsWith(\".tsx\")\n ) {\n // Skip special files\n if (entry.name === \"root.tsx\" || entry.name.startsWith(\"_\")) {\n continue\n }\n\n const relativePath = path.relative(rootDir, fullPath)\n const ext = entry.name.endsWith(\".mdx\")\n ? \".mdx\"\n : entry.name.endsWith(\".md\")\n ? \".md\"\n : \".tsx\"\n const baseName = entry.name.replace(ext, \"\")\n\n // Calculate URL path\n let urlPath: string\n if (baseName === \"index\" || baseName === \"home\") {\n // Index route - use parent directory path\n const parentDir = path.dirname(relativePath)\n urlPath = parentDir === \".\" ? \"/\" : \"/\" + parentDir.replace(/\\\\/g, \"/\")\n } else {\n // Regular route\n urlPath = \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n }\n\n // Handle dynamic segments ($param -> :param)\n urlPath = urlPath.replace(/\\$(\\w+)/g, \":$1\")\n\n routes.push({\n path: urlPath,\n file: \"routes/\" + relativePath.replace(/\\\\/g, \"/\"),\n isIndex: baseName === \"index\" || baseName === \"home\",\n })\n }\n }\n } catch {\n // Directory may not exist yet\n }\n\n return routes\n }\n\n function generateRoutesFile(routes: RouteInfo[]): string {\n // Sort routes: index routes first, then alphabetically\n const sortedRoutes = [...routes].sort((a, b) => {\n if (a.path === \"/\" && b.path !== \"/\") return -1\n if (b.path === \"/\" && a.path !== \"/\") return 1\n if (a.isIndex && !b.isIndex) return -1\n if (b.isIndex && !a.isIndex) return 1\n return a.path.localeCompare(b.path)\n })\n\n const entries = sortedRoutes.map((r) => {\n if (r.path === \"/\") {\n return ` index(\"${r.file}\"),`\n }\n // Remove leading slash for route path\n const routePath = r.path.substring(1)\n return ` route(\"${routePath}\", \"${r.file}\"),`\n })\n\n return `// AUTO-GENERATED by Ardo - Do not edit manually\n\nimport { type RouteConfig, route, index } from \"@react-router/dev/routes\"\n\nexport default [\n${entries.join(\"\\n\")}\n] satisfies RouteConfig\n`\n }\n\n function writeRoutesFileSync(): void {\n const routes = scanRoutesSync(routesDir, routesDir)\n\n // Skip if no routes found (directory might not exist yet)\n if (routes.length === 0) {\n return\n }\n\n const content = generateRoutesFile(routes)\n\n // Only write if content changed\n try {\n const existing = fsSync.readFileSync(routesFilePath, \"utf-8\")\n if (existing === content) {\n return\n }\n } catch {\n // File doesn't exist yet\n }\n\n // Ensure app directory exists\n fsSync.mkdirSync(appDir, { recursive: true })\n fsSync.writeFileSync(routesFilePath, content, \"utf-8\")\n console.log(`[ardo] Generated routes.ts with ${routes.length} routes`)\n }\n\n async function writeRoutesFile(): Promise<void> {\n const routes = scanRoutesSync(routesDir, routesDir)\n\n // Skip if no routes found (directory might not exist yet)\n if (routes.length === 0) {\n return\n }\n\n const content = generateRoutesFile(routes)\n\n // Only write if content changed\n try {\n const existing = await fs.readFile(routesFilePath, \"utf-8\")\n if (existing === content) {\n return\n }\n } catch {\n // File doesn't exist yet\n }\n\n // Ensure app directory exists\n await fs.mkdir(appDir, { recursive: true })\n await fs.writeFile(routesFilePath, content, \"utf-8\")\n }\n\n return {\n name: \"ardo:routes\",\n enforce: \"pre\",\n\n config(userConfig) {\n const root = userConfig.root || process.cwd()\n appDir = path.join(root, \"app\")\n routesDir = options.routesDir || path.join(appDir, \"routes\")\n routesFilePath = path.join(appDir, \"routes.ts\")\n\n // Generate routes synchronously during config phase\n // React Router needs routes.ts to exist before it starts\n try {\n writeRoutesFileSync()\n } catch (err) {\n console.warn(\"[ardo] Could not generate routes.ts in config phase:\", err)\n }\n },\n\n configResolved(config) {\n // Update paths if not set in config\n if (!appDir) {\n appDir = path.join(config.root, \"app\")\n routesDir = options.routesDir || path.join(appDir, \"routes\")\n routesFilePath = path.join(appDir, \"routes.ts\")\n }\n },\n\n async buildStart() {\n // Re-generate routes in buildStart for async support\n await writeRoutesFile()\n },\n\n configureServer(server) {\n // Watch for changes in routes directory\n server.watcher.add(routesDir)\n\n const handleChange = async (changedPath: string) => {\n if (\n changedPath.startsWith(routesDir) &&\n (changedPath.endsWith(\".mdx\") ||\n changedPath.endsWith(\".md\") ||\n changedPath.endsWith(\".tsx\"))\n ) {\n await writeRoutesFile()\n }\n }\n\n server.watcher.on(\"add\", handleChange)\n server.watcher.on(\"unlink\", handleChange)\n },\n }\n}\n","import type { Plugin } from \"vite\"\nimport type { MarkdownConfig } from \"../config/types\"\nimport { highlightCode } from \"../markdown/shiki\"\n\n/**\n * Strips leading/trailing blank lines and removes common leading whitespace.\n * Same logic as the runtime outdent in CodeBlock.tsx.\n */\nfunction outdent(text: string): string {\n const trimmed = text.replace(/^\\n+/, \"\").replace(/\\n\\s*$/, \"\")\n const lines = trimmed.split(\"\\n\")\n\n const indent = lines.reduce((min, line) => {\n if (line.trim().length === 0) return min\n const match = line.match(/^(\\s*)/)\n return match ? Math.min(min, match[1].length) : min\n }, Infinity)\n\n if (indent === 0 || indent === Infinity) return trimmed\n return lines.map((line) => line.slice(indent)).join(\"\\n\")\n}\n\n/**\n * Finds self-closing `<CodeBlock ... />` tags by scanning for balanced\n * quotes and braces. A simple `[^>]` regex fails when prop values contain\n * `>` characters (e.g. `code={'<Tip>Hello</Tip>'}`).\n */\nfunction findSelfClosingCodeBlocks(\n source: string\n): Array<{ fullMatch: string; propsStr: string; index: number }> {\n const results: Array<{ fullMatch: string; propsStr: string; index: number }> = []\n const tag = \"<CodeBlock\"\n let searchFrom = 0\n\n while (true) {\n const start = source.indexOf(tag, searchFrom)\n if (start === -1) break\n\n // Char after tag name must be whitespace (not > or /)\n const afterTag = start + tag.length\n if (afterTag >= source.length || !/\\s/.test(source[afterTag])) {\n searchFrom = afterTag\n continue\n }\n\n // Scan forward, skipping quoted strings and balanced braces\n let i = afterTag\n let depth = 0\n let inSingle = false\n let inDouble = false\n let inTemplate = false\n let found = false\n\n while (i < source.length) {\n const ch = source[i]\n\n // Handle escape sequences inside strings\n if ((inSingle || inDouble || inTemplate) && ch === \"\\\\\") {\n i += 2\n continue\n }\n\n if (inSingle) {\n if (ch === \"'\") inSingle = false\n i++\n continue\n }\n if (inDouble) {\n if (ch === '\"') inDouble = false\n i++\n continue\n }\n if (inTemplate) {\n if (ch === \"`\") inTemplate = false\n i++\n continue\n }\n\n if (ch === \"'\") {\n inSingle = true\n i++\n continue\n }\n if (ch === '\"') {\n inDouble = true\n i++\n continue\n }\n if (ch === \"`\") {\n inTemplate = true\n i++\n continue\n }\n if (ch === \"{\") {\n depth++\n i++\n continue\n }\n if (ch === \"}\") {\n depth--\n i++\n continue\n }\n\n // Look for /> at depth 0\n if (depth === 0 && ch === \"/\" && i + 1 < source.length && source[i + 1] === \">\") {\n const fullMatch = source.substring(start, i + 2)\n const propsStr = source.substring(afterTag, i).trim()\n results.push({ fullMatch, propsStr, index: start })\n found = true\n searchFrom = i + 2\n break\n }\n\n // If we hit > without / at depth 0, this is an opening tag, not self-closing\n if (depth === 0 && ch === \">\") {\n searchFrom = i + 1\n found = true\n break\n }\n\n i++\n }\n\n if (!found) break\n }\n\n return results\n}\n\n/**\n * Vite plugin that pre-highlights CodeBlock components at build time.\n *\n * Runs before the JSX parser, so children can contain arbitrary code\n * (including `<`, `{`, etc.) without causing syntax errors.\n *\n * Supports three patterns:\n * 1. `<CodeBlock code=\"...\" language=\"...\" />` — code prop\n * 2. `<CodeBlock language=\"...\">{\\`...\\`}</CodeBlock>` — template literal children\n * 3. `<CodeBlock language=\"...\">raw code here</CodeBlock>` — plain text children\n *\n * All patterns are rewritten to a self-closing tag with pre-rendered\n * Shiki HTML before the JSX parser ever sees them.\n */\nexport function ardoCodeBlockPlugin(markdownConfig?: MarkdownConfig): Plugin {\n return {\n name: \"ardo:codeblock-highlight\",\n enforce: \"pre\",\n\n async transform(code, id) {\n if (!/\\.[jt]sx$/.test(id)) return\n if (!code.includes(\"CodeBlock\")) return\n if (id.includes(\"node_modules\")) return\n\n let result = code\n let offset = 0\n\n // Pattern 1: Self-closing <CodeBlock code=\"...\" language=\"...\" />\n // Use a scanner instead of regex because [^>] fails when prop values\n // contain > characters (e.g. code={'<Tip>Hello</Tip>'}).\n const propMatches = findSelfClosingCodeBlocks(code)\n\n for (const match of propMatches) {\n const { fullMatch, propsStr } = match\n\n const codeMatch =\n propsStr.match(/\\bcode=\"((?:[^\"\\\\]|\\\\.)*)\"/s) ||\n propsStr.match(/\\bcode=\\{\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*\\}/s) ||\n propsStr.match(/\\bcode=\\{\\s*'((?:[^'\\\\]|\\\\.)*)'\\s*\\}/s)\n if (!codeMatch) continue\n\n const langMatch =\n propsStr.match(/\\blanguage=\"([^\"]*)\"/) ||\n propsStr.match(/\\blanguage=\\{\"([^\"]*)\"\\}/) ||\n propsStr.match(/\\blanguage=\\{'([^']*)'\\}/)\n if (!langMatch) continue\n\n if (propsStr.includes(\"__html\")) continue\n\n const codeContent = codeMatch[1]\n .replace(/\\\\n/g, \"\\n\")\n .replace(/\\\\\"/g, '\"')\n .replace(/\\\\\\\\/g, \"\\\\\")\n const language = langMatch[1]\n\n try {\n const html = await highlightCode(codeContent, language, {\n theme: markdownConfig?.theme,\n })\n\n const escapedHtml = JSON.stringify(html)\n const newPropsStr = `__html={${escapedHtml}} ` + propsStr\n const newFullMatch = fullMatch.replace(propsStr, newPropsStr)\n\n result =\n result.slice(0, match.index + offset) +\n newFullMatch +\n result.slice(match.index + offset + fullMatch.length)\n\n offset += newFullMatch.length - fullMatch.length\n } catch {\n // If highlighting fails, leave unchanged\n }\n }\n\n // Pattern 2+3: <CodeBlock language=\"...\">...children...</CodeBlock>\n // Matches both template literal children {`...`} and raw text children.\n // Since this runs before JSX parsing, raw text with <, {, etc. is fine.\n const childrenRegex = /<CodeBlock\\s+([^>]*?)>([\\s\\S]*?)<\\/CodeBlock>/g\n\n offset = result.length - code.length\n let regexMatch: RegExpExecArray | null\n while ((regexMatch = childrenRegex.exec(code)) !== null) {\n const fullMatch = regexMatch[0]\n const propsStr = regexMatch[1]\n let rawChildren = regexMatch[2]\n\n const langMatch =\n propsStr.match(/\\blanguage=\"([^\"]*)\"/) ||\n propsStr.match(/\\blanguage=\\{\"([^\"]*)\"\\}/) ||\n propsStr.match(/\\blanguage=\\{'([^']*)'\\}/)\n if (!langMatch) continue\n\n if (propsStr.includes(\"__html\")) continue\n\n // Unwrap template literal braces if present: {`...`} → ...\n const templateMatch = rawChildren.match(/^\\s*\\{`([\\s\\S]*)`\\}\\s*$/)\n if (templateMatch) {\n rawChildren = templateMatch[1]\n }\n\n const codeContent = outdent(rawChildren)\n const language = langMatch[1]\n\n try {\n const html = await highlightCode(codeContent, language, {\n theme: markdownConfig?.theme,\n })\n\n const escapedHtml = JSON.stringify(html)\n const escapedCode = JSON.stringify(codeContent)\n const newTag = `<CodeBlock __html={${escapedHtml}} code={${escapedCode}} ${propsStr} />`\n\n result =\n result.slice(0, regexMatch.index + offset) +\n newTag +\n result.slice(regexMatch.index + offset + fullMatch.length)\n\n offset += newTag.length - fullMatch.length\n } catch {\n // If highlighting fails, leave unchanged\n }\n }\n\n if (result !== code) {\n return { code: result, map: null }\n }\n },\n }\n}\n","import fs from \"fs/promises\"\nimport path from \"path\"\nimport type { PageData, PageFrontmatter, TOCItem, ResolvedConfig } from \"../config/types\"\nimport { transformMarkdown } from \"../markdown/pipeline\"\n\nexport interface LoadDocOptions {\n slug: string\n contentDir: string\n config: ResolvedConfig\n}\n\nexport interface LoadDocResult {\n content: string\n frontmatter: PageFrontmatter\n toc: TOCItem[]\n filePath: string\n relativePath: string\n lastUpdated?: number\n}\n\nexport async function loadDoc(options: LoadDocOptions): Promise<LoadDocResult | null> {\n const { slug, contentDir, config } = options\n\n const possiblePaths = [\n path.join(contentDir, `${slug}.md`),\n path.join(contentDir, slug, \"index.md\"),\n ]\n\n let filePath: string | null = null\n let fileContent: string | null = null\n\n for (const tryPath of possiblePaths) {\n try {\n fileContent = await fs.readFile(tryPath, \"utf-8\")\n filePath = tryPath\n break\n } catch {\n continue\n }\n }\n\n if (!filePath || !fileContent) {\n return null\n }\n\n const result = await transformMarkdown(fileContent, config.markdown)\n const relativePath = path.relative(contentDir, filePath)\n\n let lastUpdated: number | undefined\n try {\n const stat = await fs.stat(filePath)\n lastUpdated = stat.mtimeMs\n } catch {\n // Ignore stat errors\n }\n\n return {\n content: result.html,\n frontmatter: result.frontmatter,\n toc: result.toc,\n filePath,\n relativePath,\n lastUpdated,\n }\n}\n\nexport async function loadAllDocs(contentDir: string, config: ResolvedConfig): Promise<PageData[]> {\n const docs: PageData[] = []\n\n async function scanDir(dir: string) {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n await scanDir(fullPath)\n } else if (entry.name.endsWith(\".md\")) {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const result = await transformMarkdown(fileContent, config.markdown)\n const relativePath = path.relative(contentDir, fullPath)\n\n let lastUpdated: number | undefined\n try {\n const stat = await fs.stat(fullPath)\n lastUpdated = stat.mtimeMs\n } catch {\n // Ignore stat errors\n }\n\n docs.push({\n title: result.frontmatter.title || formatTitle(entry.name.replace(/\\.md$/, \"\")),\n description: result.frontmatter.description,\n frontmatter: result.frontmatter,\n content: result.html,\n toc: result.toc,\n filePath: fullPath,\n relativePath,\n lastUpdated,\n })\n }\n }\n }\n\n await scanDir(contentDir)\n return docs\n}\n\nfunction formatTitle(name: string): string {\n return name.replace(/[-_]/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\nexport function getSlugFromPath(relativePath: string): string {\n return relativePath\n .replace(/\\.md$/, \"\")\n .replace(/\\/index$/, \"\")\n .replace(/\\\\/g, \"/\")\n}\n\nexport function getPageDataForRoute(docs: PageData[], slug: string): PageData | undefined {\n return docs.find((doc) => {\n const docSlug = getSlugFromPath(doc.relativePath)\n return docSlug === slug || docSlug === `${slug}/index`\n })\n}\n","import { unified } from \"unified\"\nimport remarkParse from \"remark-parse\"\nimport remarkGfm from \"remark-gfm\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkRehype from \"remark-rehype\"\nimport rehypeStringify from \"rehype-stringify\"\nimport matter from \"gray-matter\"\nimport type { MarkdownConfig, TOCItem, PageFrontmatter } from \"../config/types\"\nimport { remarkExtractToc, type TocExtraction } from \"./toc\"\nimport { createShikiHighlighter, rehypeShikiFromHighlighter, type ShikiHighlighter } from \"./shiki\"\nimport { rehypeLinks } from \"./links\"\n\nexport interface TransformResult {\n html: string\n frontmatter: PageFrontmatter\n toc: TOCItem[]\n}\n\nexport interface TransformOptions {\n basePath?: string\n highlighter?: ShikiHighlighter\n}\n\nexport async function transformMarkdown(\n content: string,\n config: MarkdownConfig,\n options: TransformOptions = {}\n): Promise<TransformResult> {\n const { data: frontmatter, content: markdownContent } = matter(content)\n const { basePath = \"/\", highlighter: providedHighlighter } = options\n\n const tocExtraction: TocExtraction = { toc: [] }\n const highlighter = providedHighlighter ?? (await createShikiHighlighter(config))\n\n const processor = unified()\n .use(remarkParse)\n .use(remarkFrontmatter, [\"yaml\"])\n .use(remarkGfm)\n .use(remarkExtractToc, { tocExtraction, levels: config.toc?.level ?? [2, 3] })\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeShikiFromHighlighter, { highlighter, config })\n .use(rehypeLinks, { basePath })\n .use(rehypeStringify, { allowDangerousHtml: true })\n\n if (config.remarkPlugins) {\n for (const plugin of config.remarkPlugins) {\n processor.use(plugin as Parameters<typeof processor.use>[0])\n }\n }\n\n if (config.rehypePlugins) {\n for (const plugin of config.rehypePlugins) {\n processor.use(plugin as Parameters<typeof processor.use>[0])\n }\n }\n\n const result = await processor.process(markdownContent)\n\n return {\n html: String(result),\n frontmatter: frontmatter as PageFrontmatter,\n toc: tocExtraction.toc,\n }\n}\n\nexport async function transformMarkdownToReact(\n content: string,\n config: MarkdownConfig\n): Promise<TransformResult> {\n return transformMarkdown(content, config)\n}\n","import type { Root, Heading } from \"mdast\"\nimport { visit } from \"unist-util-visit\"\nimport type { TOCItem } from \"../config/types\"\n\nexport interface TocExtraction {\n toc: TOCItem[]\n}\n\ninterface TocOptions {\n tocExtraction: TocExtraction\n levels: [number, number]\n}\n\nexport function remarkExtractToc(options: TocOptions) {\n const { tocExtraction, levels } = options\n const [minLevel, maxLevel] = levels\n\n return function (tree: Root) {\n const headings: Array<{ text: string; level: number; id: string }> = []\n let headingIndex = 0\n\n visit(tree, \"heading\", (node: Heading) => {\n if (node.depth < minLevel || node.depth > maxLevel) {\n return\n }\n\n const text = getHeadingText(node)\n const slug = slugify(text)\n const id = slug || `heading-${headingIndex}`\n headingIndex++\n\n headings.push({\n text,\n level: node.depth,\n id,\n })\n\n // Add id to the heading node for anchor links\n const data = node.data || (node.data = {})\n const hProperties = (data.hProperties || (data.hProperties = {})) as Record<string, string>\n hProperties.id = id\n })\n\n tocExtraction.toc = buildTocTree(headings, minLevel)\n }\n}\n\nfunction getHeadingText(node: Heading): string {\n const textParts: string[] = []\n\n function extractText(child: unknown) {\n if (!child || typeof child !== \"object\") return\n\n const typedChild = child as { type?: string; value?: string; children?: unknown[] }\n\n if (typedChild.type === \"text\") {\n textParts.push(typedChild.value || \"\")\n } else if (typedChild.type === \"inlineCode\") {\n textParts.push(typedChild.value || \"\")\n } else if (Array.isArray(typedChild.children)) {\n typedChild.children.forEach(extractText)\n }\n }\n\n node.children.forEach(extractText)\n return textParts.join(\"\")\n}\n\nfunction slugify(text: string): string {\n return text\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n}\n\nfunction buildTocTree(\n headings: Array<{ text: string; level: number; id: string }>,\n _minLevel: number\n): TOCItem[] {\n const result: TOCItem[] = []\n const stack: Array<{ item: TOCItem; level: number }> = []\n\n for (const heading of headings) {\n const item: TOCItem = {\n id: heading.id,\n text: heading.text,\n level: heading.level,\n }\n\n while (stack.length > 0 && stack[stack.length - 1].level >= heading.level) {\n stack.pop()\n }\n\n if (stack.length === 0) {\n result.push(item)\n } else {\n const parent = stack[stack.length - 1].item\n if (!parent.children) {\n parent.children = []\n }\n parent.children.push(item)\n }\n\n stack.push({ item, level: heading.level })\n }\n\n return result\n}\n\nexport function flattenToc(toc: TOCItem[]): TOCItem[] {\n const result: TOCItem[] = []\n\n function flatten(items: TOCItem[]) {\n for (const item of items) {\n result.push(item)\n if (item.children) {\n flatten(item.children)\n }\n }\n }\n\n flatten(toc)\n return result\n}\n","import { visit } from \"unist-util-visit\"\nimport type { Root, Element } from \"hast\"\n\nexport interface RehypeLinkOptions {\n basePath: string\n}\n\n/**\n * Rehype plugin that rewrites internal links to include the basePath.\n * This is needed for static sites deployed to subpaths (e.g., GitHub Pages).\n */\nexport function rehypeLinks(options: RehypeLinkOptions) {\n const { basePath } = options\n\n // Normalize basePath: ensure it starts with / and doesn't end with /\n const normalizedBase = basePath === \"/\" ? \"\" : basePath.replace(/\\/$/, \"\")\n\n return (tree: Root) => {\n if (!normalizedBase) {\n // No basePath to add\n return\n }\n\n visit(tree, \"element\", (node: Element) => {\n if (node.tagName === \"a\") {\n const href = node.properties?.href\n\n if (typeof href === \"string\") {\n // Only rewrite internal links that start with /\n // Don't rewrite: external URLs, anchors, relative paths, or already prefixed paths\n if (href.startsWith(\"/\") && !href.startsWith(\"//\") && !href.startsWith(normalizedBase)) {\n node.properties = node.properties || {}\n node.properties.href = normalizedBase + href\n }\n }\n }\n })\n }\n}\n","import fs from \"fs/promises\"\nimport type { Dirent } from \"fs\"\nimport path from \"path\"\nimport matter from \"gray-matter\"\nimport type { SidebarItem, ResolvedConfig } from \"../config/types\"\n\nexport interface SidebarGenerationOptions {\n contentDir: string\n basePath: string\n config: ResolvedConfig\n}\n\nexport async function generateSidebar(options: SidebarGenerationOptions): Promise<SidebarItem[]> {\n const { contentDir, basePath, config } = options\n\n const configSidebar = config.themeConfig.sidebar\n\n if (configSidebar) {\n if (Array.isArray(configSidebar) && configSidebar.length > 0) {\n return configSidebar\n }\n if (!Array.isArray(configSidebar)) {\n return []\n }\n }\n\n return await scanDirectoryForSidebar(contentDir, contentDir, basePath)\n}\n\nasync function scanDirectoryForSidebar(\n dir: string,\n rootDir: string,\n _basePath: string\n): Promise<SidebarItem[]> {\n let entries: Dirent[]\n\n try {\n entries = (await fs.readdir(dir, { withFileTypes: true })) as Dirent[]\n } catch {\n return []\n }\n\n interface SidebarItemWithOrder extends SidebarItem {\n order?: number\n }\n\n const items: SidebarItemWithOrder[] = []\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n const relativePath = path.relative(rootDir, fullPath)\n\n if (entry.name.startsWith(\".\") || entry.name.startsWith(\"_\")) {\n continue\n }\n\n if (entry.isDirectory()) {\n const children = await scanDirectoryForSidebar(fullPath, rootDir, _basePath)\n\n if (children.length > 0) {\n const indexPath = path.join(fullPath, \"index.md\")\n let link: string | undefined\n let title = formatTitle(entry.name)\n let order: number | undefined\n\n try {\n const indexContent = await fs.readFile(indexPath, \"utf-8\")\n const { data: frontmatter } = matter(indexContent)\n\n if (frontmatter.title) {\n title = frontmatter.title\n }\n if (typeof frontmatter.order === \"number\") {\n order = frontmatter.order\n }\n\n // Don't include basePath - React Router handles it automatically\n link = normalizePath(relativePath)\n } catch {\n // No index.md file\n }\n\n items.push({\n text: title,\n link,\n collapsed: false,\n items: children,\n order,\n })\n }\n } else if (entry.name.endsWith(\".md\") && entry.name !== \"index.md\") {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const { data: frontmatter } = matter(fileContent)\n\n if (frontmatter.sidebar === false) {\n continue\n }\n\n const title = frontmatter.title || formatTitle(entry.name.replace(/\\.md$/, \"\"))\n const order = typeof frontmatter.order === \"number\" ? frontmatter.order : undefined\n\n // Don't include basePath - React Router handles it automatically\n const link = normalizePath(relativePath.replace(/\\.md$/, \"\"))\n\n items.push({\n text: title,\n link,\n order,\n })\n }\n }\n\n items.sort((a, b) => {\n if (a.order !== undefined && b.order !== undefined) {\n return a.order - b.order\n }\n if (a.order !== undefined) return -1\n if (b.order !== undefined) return 1\n return a.text.localeCompare(b.text)\n })\n\n return items.map(({ order: _order, ...item }) => item)\n}\n\nfunction formatTitle(name: string): string {\n return name\n .replace(/^\\d+-/, \"\")\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\nfunction normalizePath(p: string): string {\n return \"/\" + p.replace(/\\\\/g, \"/\").replace(/^\\/+/, \"\")\n}\n"],"mappings":";;;;;;;;;AAKA,SAAS,mBAAmB;AAC5B,OAAO,SAAS;AAChB,OAAO,uBAAuB;AAC9B,OAAO,0BAA0B;AACjC,OAAO,eAAe;AACtB,OAAO,iBAAiB;;;ACVxB;AAAA,EACE;AAAA,OAIK;AAEP,SAAS,aAAa;AAMtB,IAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,MAAM;AACR;AAEA,IAAI;AAMJ,eAAsB,cACpB,MACA,UACA,SACiB;AACjB,QAAM,cAAc,SAAS,SAAS;AAEtC,MAAI,CAAC,mBAAmB;AACtB,wBAAoB,MAAM,uBAAuB;AAAA,MAC/C,OAAO;AAAA,MACP,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;AAAA,IACvB,CAAC;AAAA,EACH;AAEA,MAAI,OAAO,gBAAgB,UAAU;AACnC,WAAO,kBAAkB,WAAW,MAAM,EAAE,MAAM,UAAU,OAAO,YAAY,CAAC;AAAA,EAClF;AAEA,SAAO,kBAAkB,WAAW,MAAM;AAAA,IACxC,MAAM;AAAA,IACN,QAAQ,EAAE,OAAO,YAAY,OAAO,MAAM,YAAY,KAAK;AAAA,IAC3D,cAAc;AAAA,EAChB,CAAC;AACH;AAEA,eAAsB,uBAAuB,QAAmD;AAC9F,QAAM,cAAc,OAAO;AAE3B,QAAM,SACJ,OAAO,gBAAgB,WAAW,CAAC,WAAW,IAAI,CAA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,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC;AAC5C;AAEA,SAAS,cAAc,GAAmB;AACxC,SAAO,MAAM,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,EAAE;AACvD;","names":["fs","fsSync","path","path","fsSync","fs","fs","path","remarkGfm","remarkFrontmatter","matter","visit","visit","matter","remarkFrontmatter","remarkGfm","path","fs","formatTitle","fs","path","matter","generateSidebar","formatTitle"]}
|