Skip to content

Commit 2547b72

Browse files
committed
Create .md versions for documentation pages
1 parent 458bb9e commit 2547b72

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

homedocs/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
[x] On this page should render closed on mobile
2727
[x] Move homedocs presets to cx-theme-variables
2828
[x] Make Stackblitz use cx-theme-variables
29-
[ ] Allow .md extension on each article
29+
[x] Allow .md extension on each article

homedocs/src/integrations/llms-txt/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ ${navIndex}`;
8383

8484
await writeFile(join(distDir, "llms.txt"), indexContent, "utf-8");
8585
console.log("✅ llms.txt generated");
86+
87+
// Generate individual .md files for each doc page
88+
let mdCount = 0;
89+
for (const page of allPages) {
90+
const mdxPath = join(srcDir, `${page.path}.mdx`);
91+
try {
92+
await access(mdxPath);
93+
const content = await extractMdxContent(mdxPath, srcDir, false);
94+
await writeFile(join(distDir, `${page.path}.md`), content, "utf-8");
95+
mdCount++;
96+
} catch {}
97+
}
98+
console.log(`✅ ${mdCount} individual .md files generated`);
8699
},
87100
},
88101
};
@@ -103,7 +116,7 @@ function generateNavigationIndex(site) {
103116
categoryLines.push(`\n#### ${group.title}`);
104117

105118
for (const item of group.items) {
106-
const url = `${site}/docs/${category.slug}/${item.slug}`;
119+
const url = `${site}/docs/${category.slug}/${item.slug}.md`;
107120
const description = item.description ? `: ${item.description}` : "";
108121
categoryLines.push(`- [${item.title}](${url})${description}`);
109122
}
@@ -211,6 +224,12 @@ async function extractMdxContent(mdxPath, srcDir, onlyStructure) {
211224
);
212225
}
213226

227+
// Replace ImportPath component with code block (before import removal)
228+
processedContent = processedContent.replace(
229+
/<ImportPath\s+path="([^"]*)"\s*\/?>/g,
230+
(_, path) => path ? "```ts\n" + path + "\n```" : "",
231+
);
232+
214233
// Remove import statements from MDX (but NOT from code blocks)
215234
// Split by code blocks, remove imports from non-code parts only
216235
const codeBlockRegex = /(```[\s\S]*?```)/g;

homedocs/src/layouts/DocsLayout.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ interface Props {
1616
const { frontmatter, title: directTitle, description: directDescription } = Astro.props;
1717
const title = frontmatter?.title || directTitle || '';
1818
const description = frontmatter?.description || directDescription || '';
19+
const mdUrl = Astro.url.pathname.replace(/\/$/, '') + '.md';
1920
---
2021

2122
<BaseLayout title={`${title} - CxJS Documentation`} description={description}>
23+
<link slot="head" rel="alternate" type="text/markdown" href={mdUrl} />
2224
<div class="min-h-screen bg-background">
2325
<Header />
2426

homedocs/src/pages/docs/intro/ai.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Following the [llms.txt](https://llmstxt.org/) standard, CxJS provides documenta
1818
| [llms-small.txt](/llms-small.txt) | Essential documentation (~100KB) | Fast context loading, basic usage |
1919
| [llms-full.txt](/llms-full.txt) | Complete documentation (~500KB) | Comprehensive reference, advanced features |
2020

21+
Additionally, every documentation page is available as a `.md` file by replacing the URL path with `.md`. For example, this page is available at [`/docs/intro/ai.md`](/docs/intro/ai.md). The `llms.txt` index links to all individual `.md` pages.
22+
2123
### Usage with AI Assistants
2224

2325
When working with AI coding assistants like Claude, ChatGPT, or Cursor, you can:

0 commit comments

Comments
 (0)