Skip to content

Commit cf12599

Browse files
committed
Include mdx files in llms-full.txt
1 parent e4a7182 commit cf12599

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

scripts/create-llms-files.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ function generateLlmsTxt() {
3333
content += `## ${category.label}\n\n`;
3434
const files = getMarkdownFiles(category.items);
3535
for (const file of files) {
36-
const filePath = path.join(docsDir, `${file}.md`);
37-
if (fs.existsSync(filePath)) {
36+
const mdPath = path.join(docsDir, `${file}.md`);
37+
const mdxPath = path.join(docsDir, `${file}.mdx`);
38+
const filePath = fs.existsSync(mdPath) ? mdPath : fs.existsSync(mdxPath) ? mdxPath : null;
39+
40+
if (filePath) {
3841
const fileContent = fs.readFileSync(filePath, 'utf-8');
3942
const match = fileContent.match(/---\s*sidebar_label:\s*"(.*?)"\s*---/);
4043
const title = match ? match[1] : path.basename(file, '.md');
@@ -61,8 +64,12 @@ function generateLlmsFullTxt() {
6164
if (match) {
6265
const url = match[2];
6366
const relativeUrl = new URL(url).pathname;
64-
const filePath = path.join(__dirname, '..', relativeUrl.substring(1) + '.md');
65-
if (fs.existsSync(filePath)) {
67+
const docPath = path.join(__dirname, '..', relativeUrl.substring(1));
68+
const mdPath = docPath + '.md';
69+
const mdxPath = docPath + '.mdx';
70+
const filePath = fs.existsSync(mdPath) ? mdPath : fs.existsSync(mdxPath) ? mdxPath : null;
71+
72+
if (filePath) {
6673
let fileContent = fs.readFileSync(filePath, 'utf-8');
6774
fileContent = fileContent.replace(/---[\s\S]*?---/, '').trim();
6875
const relativePath = path.relative(path.join(__dirname, '..'), filePath);

0 commit comments

Comments
 (0)