Elffuss BraidHub

kikocis/continue public

run prettier
Changesetf6e539b7524cdb658d0f10bfc095dce35daf7df8c6de6f38e90be47ff7e1bdf0
AuthorBrian 'bdougie' Douglas <brian@opensauced.pizza> · 2025-07-03 18:23 -07:00
CommitterBrian 'bdougie' Douglas <brian@opensauced.pizza> · 2025-07-03 18:23 -07:00
Parents4b3e1be96acc

Browse the files at this changeset

2 files changed

modified docs/docusaurus.config.js +1 −1
@@ -204,7 +204,7 @@
204204 },
205205 ],
206206 // Custom plugin for better structured llms.txt
207- require.resolve('./plugins/custom-llms-txt.js'),
207+ require.resolve("./plugins/custom-llms-txt.js"),
208208 // Keeping the original plugin commented out for now
209209 // [
210210 // "docusaurus-plugin-llms-txt",
modified docs/plugins/custom-llms-txt.js +68 −59
@@ -1,121 +1,130 @@
1-const fs = require('fs');
2-const path = require('path');
1+const fs = require("fs");
2+const path = require("path");
33
44 function getAllHtmlFiles(dir, fileList = []) {
55 const files = fs.readdirSync(dir);
6-
7- files.forEach(file => {
6+
7+ files.forEach((file) => {
88 const filePath = path.join(dir, file);
99 const stat = fs.statSync(filePath);
10-
10+
1111 if (stat.isDirectory()) {
1212 getAllHtmlFiles(filePath, fileList);
13- } else if (file === 'index.html') {
13+ } else if (file === "index.html") {
1414 fileList.push(filePath);
1515 }
1616 });
17-
17+
1818 return fileList;
1919 }
2020
2121 module.exports = function customLLMsTxtPlugin(context, options) {
2222 return {
23- name: 'custom-llms-txt',
23+ name: "custom-llms-txt",
2424 async postBuild({ siteConfig, outDir }) {
2525 // Group docs by their sidebar category
2626 const sections = {
27- 'Getting Started': [],
28- 'Features': [],
29- 'Guides': [],
30- 'Customization': [],
31- 'Advanced': [],
32- 'Hub': []
27+ "Getting Started": [],
28+ Features: [],
29+ Guides: [],
30+ Customization: [],
31+ Advanced: [],
32+ Hub: [],
3333 };
34-
34+
3535 // Get all HTML files
3636 const htmlFiles = getAllHtmlFiles(outDir);
37-
37+
3838 for (const htmlPath of htmlFiles) {
3939 try {
40- const htmlContent = fs.readFileSync(htmlPath, 'utf8');
41-
40+ const htmlContent = fs.readFileSync(htmlPath, "utf8");
41+
4242 // Extract title from HTML (handle both formats)
4343 const titleMatch = htmlContent.match(/<title[^>]*>([^<]+)<\/title>/);
44- const title = titleMatch ? titleMatch[1].replace(' | Continue', '').trim() : 'Untitled';
45-
44+ const title = titleMatch
45+ ? titleMatch[1].replace(" | Continue", "").trim()
46+ : "Untitled";
47+
4648 // Skip if title is just "Continue" (likely homepage)
47- if (title === 'Continue') continue;
48-
49+ if (title === "Continue") continue;
50+
4951 // Extract description from meta tag
50- const descMatch = htmlContent.match(/<meta\s+name="description"\s+content="([^"]+)"/);
51- const description = descMatch ? descMatch[1] : '';
52-
52+ const descMatch = htmlContent.match(
53+ /<meta\s+name="description"\s+content="([^"]+)"/,
54+ );
55+ const description = descMatch ? descMatch[1] : "";
56+
5357 // Get relative path from build directory
5458 const relativePath = path.relative(outDir, htmlPath);
5559 // Convert to URL path
56- const cleanPath = relativePath.replace(/index\.html$/, '').replace(/\/$/, '');
60+ const cleanPath = relativePath
61+ .replace(/index\.html$/, "")
62+ .replace(/\/$/, "");
5763 const url = `https://docs.continue.dev/${cleanPath}`;
58-
64+
5965 const docInfo = { title, url, description, path: cleanPath };
60-
66+
6167 // Determine section based on path
62- if (cleanPath.includes('getting-started')) {
63- sections['Getting Started'].push(docInfo);
64- } else if (cleanPath.includes('features')) {
65- sections['Features'].push(docInfo);
66- } else if (cleanPath.includes('guides')) {
67- sections['Guides'].push(docInfo);
68- } else if (cleanPath.includes('customization')) {
69- sections['Customization'].push(docInfo);
70- } else if (cleanPath.includes('advanced')) {
71- sections['Advanced'].push(docInfo);
72- } else if (cleanPath.includes('hub')) {
73- sections['Hub'].push(docInfo);
74- } else if (cleanPath === '' || cleanPath === '/') {
68+ if (cleanPath.includes("getting-started")) {
69+ sections["Getting Started"].push(docInfo);
70+ } else if (cleanPath.includes("features")) {
71+ sections["Features"].push(docInfo);
72+ } else if (cleanPath.includes("guides")) {
73+ sections["Guides"].push(docInfo);
74+ } else if (cleanPath.includes("customization")) {
75+ sections["Customization"].push(docInfo);
76+ } else if (cleanPath.includes("advanced")) {
77+ sections["Advanced"].push(docInfo);
78+ } else if (cleanPath.includes("hub")) {
79+ sections["Hub"].push(docInfo);
80+ } else if (cleanPath === "" || cleanPath === "/") {
7581 // Root page
76- sections['Getting Started'].unshift(docInfo);
82+ sections["Getting Started"].unshift(docInfo);
7783 }
7884 } catch (error) {
7985 console.warn(`Failed to process ${htmlPath}:`, error.message);
8086 }
8187 }
82-
88+
8389 // Generate the structured llms.txt content
84- let content = '# Continue Documentation\n\n';
85- content += 'Documentation for Continue - the open-source AI code assistant for developers\n\n';
86-
90+ let content = "# Continue Documentation\n\n";
91+ content +=
92+ "Documentation for Continue - the open-source AI code assistant for developers\n\n";
93+
8794 // Add each section
8895 Object.entries(sections).forEach(([sectionName, docs]) => {
8996 if (docs.length > 0) {
9097 content += `## ${sectionName}\n\n`;
91-
98+
9299 // Sort docs within each section
93100 docs.sort((a, b) => {
94101 // Sort by path depth first (shorter paths first)
95102 const depthA = (a.path.match(/\//g) || []).length;
96103 const depthB = (b.path.match(/\//g) || []).length;
97104 if (depthA !== depthB) return depthA - depthB;
98-
105+
99106 // Then alphabetically
100107 return a.path.localeCompare(b.path);
101108 });
102-
103- docs.forEach(doc => {
109+
110+ docs.forEach((doc) => {
104111 content += `- [${doc.title}](${doc.url})`;
105112 if (doc.description) {
106113 content += `: ${doc.description}`;
107114 }
108- content += '\n';
115+ content += "\n";
109116 });
110- content += '\n';
117+ content += "\n";
111118 }
112119 });
113-
120+
114121 // Write to file
115- const outputPath = path.join(outDir, 'llms.txt');
116- fs.writeFileSync(outputPath, content, 'utf8');
117-
118- console.log(`Generated structured llms.txt with ${Object.values(sections).flat().length} pages`);
119- }
122+ const outputPath = path.join(outDir, "llms.txt");
123+ fs.writeFileSync(outputPath, content, "utf8");
124+
125+ console.log(
126+ `Generated structured llms.txt with ${Object.values(sections).flat().length} pages`,
127+ );
128+ },
120129 };
121-};
No newline at the end of the file
130+};