Skip to content

Commit 0c451f4

Browse files
authored
Add LLM-friendly documentation (llms.txt) (#824)
1 parent bf8f929 commit 0c451f4

File tree

5 files changed

+112
-2
lines changed

5 files changed

+112
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,6 @@ changelog/*
107107
.atmos
108108
.python-version
109109
yarn.lock
110+
111+
**/llms.txt
112+
**/llms-full.txt

docusaurus.config.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,30 @@ async function createConfig() {
100100
redirects: getStaticRedirects(),
101101
},
102102
],
103+
[
104+
'docusaurus-plugin-llms',
105+
{
106+
generateLLMsTxt: true,
107+
generateLLMsFullTxt: true,
108+
docsDir: 'docs',
109+
includeBlog: true,
110+
includeOrder: [
111+
'into/*',
112+
'quickstart/*',
113+
'jumpstart/*',
114+
'learn/*',
115+
'layers/*',
116+
'best-practices/*',
117+
'reference/*',
118+
'components/*',
119+
'modules/*',
120+
'github-actions/*',
121+
'resources/*',
122+
'community/*',
123+
'support/*',
124+
],
125+
},
126+
],
103127
redirectsPlugin,
104128
async function AddTailwindCSS(context, options) {
105129
return {
@@ -130,7 +154,7 @@ async function createConfig() {
130154
showLastUpdateAuthor: true,
131155
// Ignore tags missing from tags.yml
132156
// There are many from components and GHA, it's too much noise without being helpful
133-
onInlineTags: 'ignore',
157+
onInlineTags: 'ignore',
134158
tags: 'tags.yml',
135159
include: ['**/*.md', '**/*.mdx']
136160
},

package-lock.json

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"docusaurus": "docusaurus",
77
"start": "docusaurus start",
88
"build": "docusaurus build",
9+
"postbuild": "cp build/llms.txt static/llms.txt && cp build/llms-full.txt static/llms-full.txt && ./scripts/clean-llms-imports.sh",
910
"swizzle": "docusaurus swizzle",
1011
"deploy": "docusaurus deploy",
1112
"clear": "docusaurus clear",
@@ -71,7 +72,8 @@
7172
"sass": "^1.77.8",
7273
"styled-jsx": "^5.1.6",
7374
"unified": "^11.0.5",
74-
"unist-util-visit": "^5.0.0"
75+
"unist-util-visit": "^5.0.0",
76+
"docusaurus-plugin-llms": "^0.2.2"
7577
},
7678
"devDependencies": {
7779
"@docusaurus/module-type-aliases": "^3.4.0",

scripts/clean-llms-imports.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Script to clean React/MDX import statements from llms.txt files
3+
# These import statements are extracted by docusaurus-plugin-llms from MDX files
4+
# and need to be removed to keep the files as plain text for LLMs
5+
6+
set -e
7+
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
STATIC_DIR="$SCRIPT_DIR/../static"
10+
11+
echo "Cleaning import statements from llms.txt files..."
12+
13+
# Clean llms.txt - replace import statements with [Description not available]
14+
if [ -f "$STATIC_DIR/llms.txt" ]; then
15+
sed -i.bak 's/: import [A-Za-z{}, ]* from ['\''"].*['\''"];*$/: [Description not available]/' "$STATIC_DIR/llms.txt"
16+
rm "$STATIC_DIR/llms.txt.bak"
17+
echo "✓ Cleaned $STATIC_DIR/llms.txt"
18+
fi
19+
20+
# Clean llms-full.txt - remove import statement lines entirely
21+
if [ -f "$STATIC_DIR/llms-full.txt" ]; then
22+
sed -i.bak '/^import [A-Za-z{}, ]* from ['\''"].*['\''"];*$/d' "$STATIC_DIR/llms-full.txt"
23+
rm "$STATIC_DIR/llms-full.txt.bak"
24+
echo "✓ Cleaned $STATIC_DIR/llms-full.txt"
25+
fi
26+
27+
echo "✓ Import cleanup complete"

0 commit comments

Comments
 (0)