diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index f611ce4bb..7e24136d4 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -203,15 +203,20 @@ const config = { enableInDevelopment: false, }, ], - [ - "docusaurus-plugin-llms-txt", - { - // Optional configuration - outputPath: "static/llms.txt", - includePatterns: ["docs/**"], - excludePatterns: ["**/node_modules/**"], - }, - ], + // Custom plugin for better structured llms.txt + require.resolve('./plugins/custom-llms-txt.js'), + // Keeping the original plugin commented out for now + // [ + // "docusaurus-plugin-llms-txt", + // { + // title: "Continue Documentation", + // description: "Documentation for Continue - the open-source AI code assistant for developers", + // // Optional configuration + // outputPath: "static/llms.txt", + // includePatterns: ["docs/**"], + // excludePatterns: ["**/node_modules/**"], + // }, + // ], [ "@docusaurus/plugin-client-redirects", { diff --git a/docs/plugins/custom-llms-txt.js b/docs/plugins/custom-llms-txt.js new file mode 100644 index 000000000..44bfbd7d5 --- /dev/null +++ b/docs/plugins/custom-llms-txt.js @@ -0,0 +1,121 @@ +const fs = require('fs'); +const path = require('path'); + +function getAllHtmlFiles(dir, fileList = []) { + const files = fs.readdirSync(dir); + + files.forEach(file => { + const filePath = path.join(dir, file); + const stat = fs.statSync(filePath); + + if (stat.isDirectory()) { + getAllHtmlFiles(filePath, fileList); + } else if (file === 'index.html') { + fileList.push(filePath); + } + }); + + return fileList; +} + +module.exports = function customLLMsTxtPlugin(context, options) { + return { + name: 'custom-llms-txt', + async postBuild({ siteConfig, outDir }) { + // Group docs by their sidebar category + const sections = { + 'Getting Started': [], + 'Features': [], + 'Guides': [], + 'Customization': [], + 'Advanced': [], + 'Hub': [] + }; + + // Get all HTML files + const htmlFiles = getAllHtmlFiles(outDir); + + for (const htmlPath of htmlFiles) { + try { + const htmlContent = fs.readFileSync(htmlPath, 'utf8'); + + // Extract title from HTML (handle both formats) + const titleMatch = htmlContent.match(/