docusaurus-plugin-llms 0.1.2 → 0.1.3

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.
package/README.md CHANGED
@@ -39,6 +39,13 @@ module.exports = {
39
39
  title: 'My Project Documentation',
40
40
  description: 'Complete reference documentation for My Project',
41
41
  includeBlog: true,
42
+ // Control documentation order
43
+ includeOrder: [
44
+ 'getting-started/*',
45
+ 'guides/*',
46
+ 'api/*',
47
+ ],
48
+ includeUnmatchedLast: true,
42
49
  // Path transformation options
43
50
  pathTransformation: {
44
51
  // Paths to ignore when constructing URLs (will be removed if found)
@@ -46,6 +53,23 @@ module.exports = {
46
53
  // Paths to add when constructing URLs (will be prepended if not already present)
47
54
  addPaths: ['api'],
48
55
  },
56
+ // Custom LLM files for specific documentation sections
57
+ customLLMFiles: [
58
+ {
59
+ filename: 'llms-python.txt',
60
+ includePatterns: ['api/python/**/*.md', 'guides/python/*.md'],
61
+ fullContent: true,
62
+ title: 'Python API Documentation',
63
+ description: 'Complete reference for Python API'
64
+ },
65
+ {
66
+ filename: 'llms-tutorials.txt',
67
+ includePatterns: ['tutorials/**/*.md'],
68
+ fullContent: false,
69
+ title: 'Tutorial Documentation',
70
+ description: 'All tutorials in a single file'
71
+ }
72
+ ],
49
73
  },
50
74
  ],
51
75
  // ... your other plugins
@@ -55,20 +79,24 @@ module.exports = {
55
79
 
56
80
  ### Available Options
57
81
 
58
- | Option | Type | Default | Description |
59
- |-----------------------|----------|-------------------|----------------------------------------------|
60
- | `generateLLMsTxt` | boolean | `true` | Whether to generate the links file |
61
- | `generateLLMsFullTxt` | boolean | `true` | Whether to generate the full content file |
62
- | `docsDir` | string | `'docs'` | Base directory for documentation files |
63
- | `ignoreFiles` | string[] | `[]` | Array of glob patterns for files to ignore |
64
- | `title` | string | Site title | Custom title to use in generated files |
65
- | `description` | string | Site tagline | Custom description to use in generated files |
66
- | `llmsTxtFilename` | string | `'llms.txt'` | Custom filename for the links file |
67
- | `llmsFullTxtFilename` | string | `'llms-full.txt'` | Custom filename for the full content file |
68
- | `includeBlog` | boolean | `false` | Whether to include blog content |
69
- | `pathTransformation` | object | `undefined` | Path transformation options for URL construction |
70
- | `pathTransformation.ignorePaths` | string[] | `[]` | Path segments to ignore when constructing URLs |
71
- | `pathTransformation.addPaths` | string[] | `[]` | Path segments to add when constructing URLs |
82
+ | Option | Type | Default | Description |
83
+ |----------------------------------|----------|-------------------|---------------------------------------------------------------|
84
+ | `description` | string | Site tagline | Custom description to use in generated files |
85
+ | `docsDir` | string | `'docs'` | Base directory for documentation files |
86
+ | `generateLLMsFullTxt` | boolean | `true` | Whether to generate the full content file |
87
+ | `generateLLMsTxt` | boolean | `true` | Whether to generate the links file |
88
+ | `ignoreFiles` | string[] | `[]` | Array of glob patterns for files to ignore |
89
+ | `includeBlog` | boolean | `false` | Whether to include blog content |
90
+ | `includeOrder` | string[] | `[]` | Array of glob patterns for files to process in specific order |
91
+ | `includeUnmatchedLast` | boolean | `true` | Whether to include unmatched files at the end |
92
+ | `llmsFullTxtFilename` | string | `'llms-full.txt'` | Custom filename for the full content file |
93
+ | `llmsTxtFilename` | string | `'llms.txt'` | Custom filename for the links file |
94
+ | `pathTransformation.addPaths` | string[] | `[]` | Path segments to add when constructing URLs |
95
+ | `pathTransformation.ignorePaths` | string[] | `[]` | Path segments to ignore when constructing URLs |
96
+ | `pathTransformation` | object | `undefined` | Path transformation options for URL construction |
97
+ | `title` | string | Site title | Custom title to use in generated files |
98
+ | `version` | string | `undefined` | Global version to include in all generated files |
99
+ | `customLLMFiles` | array | `[]` | Array of custom LLM file configurations |
72
100
 
73
101
  ### Path Transformation Examples
74
102
 
@@ -101,12 +129,204 @@ File path: `/content/docs/manual/decorators.md` → URL: `https://example.com/ap
101
129
 
102
130
  The configuration supports multiple path segments in both arrays.
103
131
 
132
+ ### Document Ordering Examples
133
+
134
+ The document ordering feature allows you to control the sequence in which files appear in the generated output:
135
+
136
+ **Example 1**: Basic Section Ordering
137
+ ```js
138
+ includeOrder: [
139
+ 'getting-started/*',
140
+ 'guides/*',
141
+ 'api/*',
142
+ 'advanced/*'
143
+ ]
144
+ ```
145
+ Result: Files will appear in the generated output following this section order.
146
+
147
+ **Example 2**: Strict Inclusion List
148
+ ```js
149
+ includeOrder: [
150
+ 'public-docs/**/*.md'
151
+ ],
152
+ includeUnmatchedLast: false
153
+ ```
154
+ Result: Only files matching 'public-docs/**/*.md' are included, all others are excluded.
155
+
156
+ **Example 3**: Detailed Ordering with Specific Files First
157
+ ```js
158
+ includeOrder: [
159
+ 'getting-started/installation.md',
160
+ 'getting-started/quick-start.md',
161
+ 'getting-started/*.md',
162
+ 'api/core/*.md',
163
+ 'api/plugins/*.md',
164
+ 'api/**/*.md'
165
+ ]
166
+ ```
167
+ Result: Installation and quick-start guides appear first, followed by other getting-started files, then API documentation in a specific order.
168
+
169
+ ### Custom LLM Files
170
+
171
+ In addition to the standard `llms.txt` and `llms-full.txt` files, you can generate custom LLM-friendly files for different sections of your documentation with the `customLLMFiles` option:
172
+
173
+ ```js
174
+ customLLMFiles: [
175
+ {
176
+ filename: 'llms-python.txt',
177
+ includePatterns: ['api/python/**/*.md', 'guides/python/*.md'],
178
+ fullContent: true,
179
+ title: 'Python API Documentation',
180
+ description: 'Complete reference for Python API'
181
+ },
182
+ {
183
+ filename: 'llms-tutorials.txt',
184
+ includePatterns: ['tutorials/**/*.md'],
185
+ fullContent: false,
186
+ title: 'Tutorial Documentation',
187
+ description: 'All tutorials in a single file'
188
+ }
189
+ ]
190
+ ```
191
+
192
+ #### Custom LLM File Configuration
193
+
194
+ Each custom LLM file is defined by an object with the following properties:
195
+
196
+ | Option | Type | Required | Description |
197
+ |-----------------------|----------|----------|----------------------------------------------|
198
+ | `filename` | string | Yes | Name of the output file (e.g., 'llms-python.txt') |
199
+ | `includePatterns` | string[] | Yes | Glob patterns for files to include |
200
+ | `fullContent` | boolean | Yes | `true` for full content like llms-full.txt, `false` for links only like llms.txt |
201
+ | `title` | string | No | Custom title for this file (defaults to site title) |
202
+ | `description` | string | No | Custom description for this file (defaults to site description) |
203
+ | `ignorePatterns` | string[] | No | Additional patterns to exclude (combined with global ignoreFiles) |
204
+ | `orderPatterns` | string[] | No | Order patterns for controlling file ordering (similar to includeOrder) |
205
+ | `includeUnmatchedLast`| boolean | No | Whether to include unmatched files last (default: false) |
206
+ | `version` | string | No | Version information for this LLM file (overrides global version) |
207
+
208
+ #### Use Cases
209
+
210
+ ##### Language-Specific Documentation
211
+
212
+ Create separate files for different programming languages:
213
+
214
+ ```js
215
+ customLLMFiles: [
216
+ {
217
+ filename: 'llms-python.txt',
218
+ includePatterns: ['api/python/**/*.md', 'guides/python/*.md'],
219
+ fullContent: true,
220
+ title: 'Python API Documentation'
221
+ },
222
+ {
223
+ filename: 'llms-javascript.txt',
224
+ includePatterns: ['api/javascript/**/*.md', 'guides/javascript/*.md'],
225
+ fullContent: true,
226
+ title: 'JavaScript API Documentation'
227
+ }
228
+ ]
229
+ ```
230
+
231
+ ##### Content Type Separation
232
+
233
+ Separate tutorials from API reference:
234
+
235
+ ```js
236
+ customLLMFiles: [
237
+ {
238
+ filename: 'llms-tutorials.txt',
239
+ includePatterns: ['tutorials/**/*.md', 'guides/**/*.md'],
240
+ fullContent: true,
241
+ title: 'Tutorials and Guides'
242
+ },
243
+ {
244
+ filename: 'llms-api.txt',
245
+ includePatterns: ['api/**/*.md', 'reference/**/*.md'],
246
+ fullContent: true,
247
+ title: 'API Reference'
248
+ }
249
+ ]
250
+ ```
251
+
252
+ ##### Beginner-Friendly Documentation
253
+
254
+ Create a beginner-focused file with carefully ordered content:
255
+
256
+ ```js
257
+ customLLMFiles: [
258
+ {
259
+ filename: 'llms-getting-started.txt',
260
+ includePatterns: ['**/*.md'],
261
+ ignorePatterns: ['advanced/**/*.md', 'internal/**/*.md'],
262
+ orderPatterns: [
263
+ 'introduction.md',
264
+ 'getting-started/*.md',
265
+ 'tutorials/basic/*.md',
266
+ 'examples/simple/*.md'
267
+ ],
268
+ fullContent: true,
269
+ title: 'Getting Started Guide',
270
+ description: 'Beginner-friendly documentation with essential concepts'
271
+ }
272
+ ]
273
+ ```
274
+
275
+ ##### Versioned Documentation
276
+
277
+ Include version information in your documentation files:
278
+
279
+ ```js
280
+ plugins: [
281
+ [
282
+ 'docusaurus-plugin-llms',
283
+ {
284
+ // Global version applies to all files
285
+ version: '2.0.0',
286
+
287
+ // Custom LLM files with specific versions
288
+ customLLMFiles: [
289
+ {
290
+ filename: 'api-reference.txt',
291
+ title: 'API Reference Documentation',
292
+ description: 'Complete API reference for developers',
293
+ includePatterns: ['**/api/**/*.md', '**/reference/**/*.md'],
294
+ fullContent: true,
295
+ version: '1.0.0' // Overrides global version
296
+ },
297
+ {
298
+ filename: 'tutorials.txt',
299
+ title: 'Tutorials and Guides',
300
+ description: 'Step-by-step tutorials and guides',
301
+ includePatterns: ['**/tutorials/**/*.md', '**/guides/**/*.md'],
302
+ fullContent: true,
303
+ version: '0.9.5-beta' // Overrides global version
304
+ }
305
+ ]
306
+ }
307
+ ],
308
+ ]
309
+ ```
310
+
311
+ The generated files will include the version information under the description:
312
+
313
+ ```
314
+ # API Reference Documentation
315
+
316
+ > Complete API reference for developers
317
+
318
+ Version: 1.0.0
319
+
320
+ This file contains all documentation content in a single document following the llmtxt.org standard.
321
+ ```
322
+
104
323
  ## How It Works
105
324
 
106
325
  This plugin automatically generates the following files during the build process:
107
326
 
108
327
  - **llms.txt**: Contains links to all sections of your documentation
109
328
  - **llms-full.txt**: Contains all documentation content in a single file
329
+ - **Custom LLM files**: Additional files based on your custom configurations
110
330
 
111
331
  These files follow the [llmstxt standard](https://llmstxt.org/), making your documentation optimized for use with Large Language Models (LLMs).
112
332
 
@@ -117,10 +337,12 @@ These files follow the [llmstxt standard](https://llmstxt.org/), making your doc
117
337
  - ⚙️ Highly customizable with multiple options
118
338
  - 📝 Creates `llms.txt` with section links
119
339
  - 📖 Produces `llms-full.txt` with all content in one file
340
+ - 📋 Document ordering control for custom sequence
341
+ - 🔄 Path transformation to customize URL construction
342
+ - 📚 Option to include blog posts
343
+ - 🧩 Custom LLM files for specific documentation sections
120
344
  - 🧹 Cleans HTML and normalizes content for optimal LLM consumption
121
345
  - 📊 Provides statistics about generated documentation
122
- - 📚 Option to include blog posts
123
- - 🔄 Path transformation to customize URL construction
124
346
 
125
347
  ## Implementation Details
126
348
 
@@ -128,12 +350,14 @@ The plugin:
128
350
 
129
351
  1. Scans your `docs` directory recursively for all Markdown files
130
352
  2. Optionally includes blog content
131
- 3. Extracts metadata, titles, and content from each file
132
- 4. Creates proper URL links to each document section
133
- 5. Applies path transformations according to configuration (removing or adding path segments)
134
- 6. Generates a table of contents in `llms.txt`
135
- 7. Combines all documentation content in `llms-full.txt`
136
- 8. Provides statistics about the generated documentation
353
+ 3. Orders documents according to specified glob patterns (if provided)
354
+ 4. Extracts metadata, titles, and content from each file
355
+ 5. Creates proper URL links to each document section
356
+ 6. Applies path transformations according to configuration (removing or adding path segments)
357
+ 7. Generates a table of contents in `llms.txt`
358
+ 8. Combines all documentation content in `llms-full.txt`
359
+ 9. Creates custom LLM files based on specified configurations
360
+ 10. Provides statistics about the generated documentation
137
361
 
138
362
  ## Testing
139
363
 
@@ -0,0 +1,32 @@
1
+ /**
2
+ * LLM file generation functions for the docusaurus-plugin-llms plugin
3
+ */
4
+ import { DocInfo, PluginContext } from './types';
5
+ /**
6
+ * Generate an LLM-friendly file
7
+ * @param docs - Processed document information
8
+ * @param outputPath - Path to write the output file
9
+ * @param fileTitle - Title for the file
10
+ * @param fileDescription - Description for the file
11
+ * @param includeFullContent - Whether to include full content or just links
12
+ * @param version - Version of the file
13
+ */
14
+ export declare function generateLLMFile(docs: DocInfo[], outputPath: string, fileTitle: string, fileDescription: string, includeFullContent: boolean, version?: string): Promise<void>;
15
+ /**
16
+ * Generate standard LLM files (llms.txt and llms-full.txt)
17
+ * @param context - Plugin context
18
+ * @param allDocFiles - Array of all document files
19
+ */
20
+ export declare function generateStandardLLMFiles(context: PluginContext, allDocFiles: string[]): Promise<void>;
21
+ /**
22
+ * Generate custom LLM files based on configuration
23
+ * @param context - Plugin context
24
+ * @param allDocFiles - Array of all document files
25
+ */
26
+ export declare function generateCustomLLMFiles(context: PluginContext, allDocFiles: string[]): Promise<void>;
27
+ /**
28
+ * Collect all document files from docs directory and optionally blog
29
+ * @param context - Plugin context
30
+ * @returns Array of file paths
31
+ */
32
+ export declare function collectDocFiles(context: PluginContext): Promise<string[]>;
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ /**
3
+ * LLM file generation functions for the docusaurus-plugin-llms plugin
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.generateLLMFile = generateLLMFile;
40
+ exports.generateStandardLLMFiles = generateStandardLLMFiles;
41
+ exports.generateCustomLLMFiles = generateCustomLLMFiles;
42
+ exports.collectDocFiles = collectDocFiles;
43
+ const path = __importStar(require("path"));
44
+ const fs = __importStar(require("fs/promises"));
45
+ const utils_1 = require("./utils");
46
+ const processor_1 = require("./processor");
47
+ /**
48
+ * Clean a description for use in a TOC item
49
+ * @param description - The original description
50
+ * @returns Cleaned description suitable for TOC
51
+ */
52
+ function cleanDescriptionForToc(description) {
53
+ if (!description)
54
+ return '';
55
+ // Get just the first line for TOC display
56
+ const firstLine = description.split('\n')[0];
57
+ // Remove heading markers only at the beginning of the line
58
+ // Be careful to only remove actual heading markers (# followed by space at beginning)
59
+ // and not hashtag symbols that are part of the content (inline hashtags)
60
+ const cleaned = firstLine.replace(/^(#+)\s+/g, '');
61
+ // Truncate if too long (150 characters max with ellipsis)
62
+ return cleaned.length > 150 ? cleaned.substring(0, 147) + '...' : cleaned;
63
+ }
64
+ /**
65
+ * Generate an LLM-friendly file
66
+ * @param docs - Processed document information
67
+ * @param outputPath - Path to write the output file
68
+ * @param fileTitle - Title for the file
69
+ * @param fileDescription - Description for the file
70
+ * @param includeFullContent - Whether to include full content or just links
71
+ * @param version - Version of the file
72
+ */
73
+ async function generateLLMFile(docs, outputPath, fileTitle, fileDescription, includeFullContent, version) {
74
+ console.log(`Generating file: ${outputPath}, version: ${version || 'undefined'}`);
75
+ const versionInfo = version ? `\n\nVersion: ${version}` : '';
76
+ if (includeFullContent) {
77
+ // Generate full content file
78
+ const fullContentSections = docs.map(doc => {
79
+ return `## ${doc.title}
80
+
81
+ ${doc.content}`;
82
+ });
83
+ const llmFileContent = `# ${fileTitle}
84
+
85
+ > ${fileDescription}${versionInfo}
86
+
87
+ This file contains all documentation content in a single document following the llmtxt.org standard.
88
+
89
+ ${fullContentSections.join('\n\n---\n\n')}
90
+ `;
91
+ await (0, utils_1.writeFile)(outputPath, llmFileContent);
92
+ }
93
+ else {
94
+ // Generate links-only file
95
+ const tocItems = docs.map(doc => {
96
+ // Clean and format the description for TOC
97
+ const cleanedDescription = cleanDescriptionForToc(doc.description);
98
+ return `- [${doc.title}](${doc.url})${cleanedDescription ? `: ${cleanedDescription}` : ''}`;
99
+ });
100
+ const llmFileContent = `# ${fileTitle}
101
+
102
+ > ${fileDescription}${versionInfo}
103
+
104
+ This file contains links to documentation sections following the llmtxt.org standard.
105
+
106
+ ## Table of Contents
107
+
108
+ ${tocItems.join('\n')}
109
+ `;
110
+ await (0, utils_1.writeFile)(outputPath, llmFileContent);
111
+ }
112
+ console.log(`Generated: ${outputPath}`);
113
+ }
114
+ /**
115
+ * Generate standard LLM files (llms.txt and llms-full.txt)
116
+ * @param context - Plugin context
117
+ * @param allDocFiles - Array of all document files
118
+ */
119
+ async function generateStandardLLMFiles(context, allDocFiles) {
120
+ const { outDir, docTitle, docDescription, options } = context;
121
+ const { generateLLMsTxt, generateLLMsFullTxt, llmsTxtFilename = 'llms.txt', llmsFullTxtFilename = 'llms-full.txt', includeOrder = [], includeUnmatchedLast = true, version } = options;
122
+ if (!generateLLMsTxt && !generateLLMsFullTxt) {
123
+ return;
124
+ }
125
+ // Process files for the standard outputs
126
+ const processedDocs = await (0, processor_1.processFilesWithPatterns)(context, allDocFiles, [], // No specific include patterns - include all
127
+ [], // No additional ignore patterns beyond global ignoreFiles
128
+ includeOrder, includeUnmatchedLast);
129
+ console.log(`Processed ${processedDocs.length} documentation files for standard LLM files`);
130
+ // Generate llms.txt
131
+ if (generateLLMsTxt) {
132
+ const llmsTxtPath = path.join(outDir, llmsTxtFilename);
133
+ await generateLLMFile(processedDocs, llmsTxtPath, docTitle, docDescription, false, // links only
134
+ version);
135
+ }
136
+ // Generate llms-full.txt
137
+ if (generateLLMsFullTxt) {
138
+ const llmsFullTxtPath = path.join(outDir, llmsFullTxtFilename);
139
+ await generateLLMFile(processedDocs, llmsFullTxtPath, docTitle, docDescription, true, // full content
140
+ version);
141
+ }
142
+ }
143
+ /**
144
+ * Generate custom LLM files based on configuration
145
+ * @param context - Plugin context
146
+ * @param allDocFiles - Array of all document files
147
+ */
148
+ async function generateCustomLLMFiles(context, allDocFiles) {
149
+ const { outDir, docTitle, docDescription, options } = context;
150
+ const { customLLMFiles = [], ignoreFiles = [] } = options;
151
+ if (customLLMFiles.length === 0) {
152
+ return;
153
+ }
154
+ console.log(`Generating ${customLLMFiles.length} custom LLM files...`);
155
+ for (const customFile of customLLMFiles) {
156
+ console.log(`Processing custom file: ${customFile.filename}, version: ${customFile.version || 'undefined'}`);
157
+ // Combine global ignores with custom ignores
158
+ const combinedIgnores = [...ignoreFiles];
159
+ if (customFile.ignorePatterns) {
160
+ combinedIgnores.push(...customFile.ignorePatterns);
161
+ }
162
+ // Process files according to the custom configuration
163
+ const customDocs = await (0, processor_1.processFilesWithPatterns)(context, allDocFiles, customFile.includePatterns, combinedIgnores, customFile.orderPatterns || [], customFile.includeUnmatchedLast ?? false);
164
+ if (customDocs.length > 0) {
165
+ // Use custom title/description or fall back to defaults
166
+ const customTitle = customFile.title || docTitle;
167
+ const customDescription = customFile.description || docDescription;
168
+ // Generate the custom LLM file
169
+ const customFilePath = path.join(outDir, customFile.filename);
170
+ await generateLLMFile(customDocs, customFilePath, customTitle, customDescription, customFile.fullContent, customFile.version);
171
+ console.log(`Generated custom LLM file: ${customFile.filename} with ${customDocs.length} documents`);
172
+ }
173
+ else {
174
+ console.warn(`No matching documents found for custom LLM file: ${customFile.filename}`);
175
+ }
176
+ }
177
+ }
178
+ /**
179
+ * Collect all document files from docs directory and optionally blog
180
+ * @param context - Plugin context
181
+ * @returns Array of file paths
182
+ */
183
+ async function collectDocFiles(context) {
184
+ const { siteDir, docsDir, options } = context;
185
+ const { ignoreFiles = [], includeBlog = false } = options;
186
+ const allDocFiles = [];
187
+ // Process docs directory
188
+ const fullDocsDir = path.join(siteDir, docsDir);
189
+ try {
190
+ await fs.access(fullDocsDir);
191
+ // Collect all markdown files from docs directory
192
+ const docFiles = await (0, utils_1.readMarkdownFiles)(fullDocsDir, siteDir, ignoreFiles);
193
+ allDocFiles.push(...docFiles);
194
+ }
195
+ catch (err) {
196
+ console.warn(`Docs directory not found: ${fullDocsDir}`);
197
+ }
198
+ // Process blog if enabled
199
+ if (includeBlog) {
200
+ const blogDir = path.join(siteDir, 'blog');
201
+ try {
202
+ await fs.access(blogDir);
203
+ // Collect all markdown files from blog directory
204
+ const blogFiles = await (0, utils_1.readMarkdownFiles)(blogDir, siteDir, ignoreFiles);
205
+ allDocFiles.push(...blogFiles);
206
+ }
207
+ catch (err) {
208
+ console.warn(`Blog directory not found: ${blogDir}`);
209
+ }
210
+ }
211
+ return allDocFiles;
212
+ }
package/lib/index.d.ts CHANGED
@@ -8,36 +8,7 @@
8
8
  * The plugin runs during the Docusaurus build process and scans all Markdown files in the docs directory.
9
9
  */
10
10
  import type { LoadContext, Plugin } from '@docusaurus/types';
11
- /**
12
- * Plugin options interface
13
- */
14
- interface PluginOptions {
15
- /** Whether to generate the llms.txt file (default: true) */
16
- generateLLMsTxt?: boolean;
17
- /** Whether to generate the llms-full.txt file (default: true) */
18
- generateLLMsFullTxt?: boolean;
19
- /** Base directory for documentation files (default: 'docs') */
20
- docsDir?: string;
21
- /** Array of glob patterns for files to ignore */
22
- ignoreFiles?: string[];
23
- /** Custom title to use in generated files (defaults to site title) */
24
- title?: string;
25
- /** Custom description to use in generated files (defaults to site tagline) */
26
- description?: string;
27
- /** Custom file name for the links file (default: 'llms.txt') */
28
- llmsTxtFilename?: string;
29
- /** Custom file name for the full content file (default: 'llms-full.txt') */
30
- llmsFullTxtFilename?: string;
31
- /** Whether to include blog content (default: false) */
32
- includeBlog?: boolean;
33
- /** Path transformation options for URL construction */
34
- pathTransformation?: {
35
- /** Path segments to ignore when constructing URLs (will be removed if found) */
36
- ignorePaths?: string[];
37
- /** Path segments to add when constructing URLs (will be prepended if not already present) */
38
- addPaths?: string[];
39
- };
40
- }
11
+ import { PluginOptions } from './types';
41
12
  /**
42
13
  * A Docusaurus plugin to generate LLM-friendly documentation following
43
14
  * the llmtxt.org standard
@@ -47,4 +18,3 @@ interface PluginOptions {
47
18
  * @returns Plugin object
48
19
  */
49
20
  export default function docusaurusPluginLLMs(context: LoadContext, options?: PluginOptions): Plugin<void>;
50
- export {};