Skip to content

Commit 5b92705

Browse files
committed
enhance LLMs build process: add URL fixing script, update build command, and implement verification steps in CI workflow
1 parent 6955a92 commit 5b92705

File tree

4 files changed

+116
-10
lines changed

4 files changed

+116
-10
lines changed

.github/workflows/deploy.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,42 @@ jobs:
2525
cache: "npm"
2626
- name: Install dependencies
2727
run: npm ci
28-
- name: Build website
29-
run: npm run build
28+
- name: Build website with LLMs generation
29+
run: npm run build:llms-fixed
30+
- name: Verify LLMs files
31+
run: |
32+
echo "Verifying LLMs files generation..."
33+
34+
# Check if LLMs files were generated
35+
if [ ! -f "build/llms.txt" ] || [ ! -f "build/llms-full.txt" ]; then
36+
echo "❌ LLMs files not found!"
37+
exit 1
38+
fi
39+
40+
# Check file sizes
41+
llms_txt_size=$(wc -c < build/llms.txt)
42+
llms_full_size=$(wc -c < build/llms-full.txt)
43+
echo "llms.txt: $llms_txt_size bytes"
44+
echo "llms-full.txt: $llms_full_size bytes"
45+
46+
# Verify URLs are correct (no prepended numbers)
47+
if grep -q "https://dev\.flare\.network/docs/[^)]*/\d+-" build/llms.txt; then
48+
echo "❌ Found URLs with prepended numbers!"
49+
exit 1
50+
else
51+
echo "✅ All URLs are correctly formatted"
52+
fi
53+
54+
# Check content structure
55+
sections=$(grep -c "^- \[" build/llms.txt || true)
56+
echo "Found $sections sections in llms.txt"
57+
58+
if [ "$sections" -lt 10 ]; then
59+
echo "❌ Too few sections found!"
60+
exit 1
61+
fi
62+
63+
echo "✅ LLMs files verified successfully"
3064
- name: Upload Build Artifact
3165
uses: actions/upload-pages-artifact@v3
3266
with:

docusaurus.config.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,19 @@ const config: Config = {
249249
"docusaurus-plugin-llms",
250250
{
251251
ignoreFiles: ["**/node_modules/**", "**/.git/**", "**/*.txt"],
252-
// Include order for better organization
253252
includeOrder: [
254-
"network",
255-
"ftso",
256-
"fdc",
257-
"fassets",
258-
"run-node",
259-
"support",
253+
"**/network/**/*.mdx",
254+
"**/network/**/*.md",
255+
"**/ftso/**/*.mdx",
256+
"**/ftso/**/*.md",
257+
"**/fdc/**/*.mdx",
258+
"**/fdc/**/*.md",
259+
"**/fassets/**/*.mdx",
260+
"**/fassets/**/*.md",
261+
"**/run-node/**/*.mdx",
262+
"**/run-node/**/*.md",
263+
"**/support/**/*.mdx",
264+
"**/support/**/*.md",
260265
],
261266
// Content cleaning options for better LLM consumption
262267
excludeImports: true,

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"format:diff": "prettier --list-different .",
2020
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,md,mdx}\"",
2121
"lint": "npx eslint .",
22-
"build:llms": "npm run build"
22+
"fix-llms-urls": "node scripts/fix-llms-urls.js",
23+
"build:llms-fixed": "npm run build && npm run fix-llms-urls"
2324
},
2425
"dependencies": {
2526
"@docusaurus/core": "^3.8.1",

scripts/fix-llms-urls.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script to fix URLs in generated LLMs files to match Docusaurus routing
5+
*
6+
* This script removes prepended numbers from URLs to match how Docusaurus
7+
* generates routes (e.g., "0-overview" becomes "overview")
8+
*/
9+
10+
const fs = require('fs');
11+
const path = require('path');
12+
13+
const config = {
14+
buildDir: 'build',
15+
filesToFix: ['llms.txt', 'llms-full.txt'],
16+
baseUrl: 'https://dev.flare.network/docs/',
17+
};
18+
19+
function fixUrlsInFile(filePath) {
20+
try {
21+
console.log(`Fixing URLs in: ${filePath}`);
22+
23+
const content = fs.readFileSync(filePath, 'utf8');
24+
25+
// Fix URLs by removing prepended numbers
26+
// Pattern: https://dev.flare.network/docs/network/0-overview -> https://dev.flare.network/docs/network/overview
27+
const fixedContent = content.replace(
28+
/(https:\/\/dev\.flare\.network\/docs\/[^)]+\/)\d+-([^)]+)/g,
29+
'$1$2'
30+
);
31+
32+
fs.writeFileSync(filePath, fixedContent);
33+
34+
console.log(`✅ Fixed URLs in: ${filePath}`);
35+
36+
} catch (error) {
37+
console.error(`❌ Error fixing URLs in ${filePath}:`, error.message);
38+
}
39+
}
40+
41+
function main() {
42+
console.log('🔧 Fixing URLs in LLMs files...');
43+
44+
if (!fs.existsSync(config.buildDir)) {
45+
console.error(`❌ Build directory not found: ${config.buildDir}`);
46+
return;
47+
}
48+
49+
config.filesToFix.forEach(fileName => {
50+
const filePath = path.join(config.buildDir, fileName);
51+
52+
if (fs.existsSync(filePath)) {
53+
fixUrlsInFile(filePath);
54+
} else {
55+
console.warn(`⚠️ File not found: ${filePath}`);
56+
}
57+
});
58+
59+
console.log('✅ URL fixing completed!');
60+
}
61+
62+
if (require.main === module) {
63+
main();
64+
}
65+
66+
module.exports = { fixUrlsInFile, main };

0 commit comments

Comments
 (0)