Skip to content

Commit 395ffb4

Browse files
committed
refactor: clean up whitespace and improve URL fixing script for LLMs files
1 parent 5b92705 commit 395ffb4

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,36 @@ jobs:
3030
- name: Verify LLMs files
3131
run: |
3232
echo "Verifying LLMs files generation..."
33-
33+
3434
# Check if LLMs files were generated
3535
if [ ! -f "build/llms.txt" ] || [ ! -f "build/llms-full.txt" ]; then
3636
echo "❌ LLMs files not found!"
3737
exit 1
3838
fi
39-
39+
4040
# Check file sizes
4141
llms_txt_size=$(wc -c < build/llms.txt)
4242
llms_full_size=$(wc -c < build/llms-full.txt)
4343
echo "llms.txt: $llms_txt_size bytes"
4444
echo "llms-full.txt: $llms_full_size bytes"
45-
45+
4646
# Verify URLs are correct (no prepended numbers)
4747
if grep -q "https://dev\.flare\.network/docs/[^)]*/\d+-" build/llms.txt; then
4848
echo "❌ Found URLs with prepended numbers!"
4949
exit 1
5050
else
5151
echo "✅ All URLs are correctly formatted"
5252
fi
53-
53+
5454
# Check content structure
5555
sections=$(grep -c "^- \[" build/llms.txt || true)
5656
echo "Found $sections sections in llms.txt"
57-
57+
5858
if [ "$sections" -lt 10 ]; then
5959
echo "❌ Too few sections found!"
6060
exit 1
6161
fi
62-
62+
6363
echo "✅ LLMs files verified successfully"
6464
- name: Upload Build Artifact
6565
uses: actions/upload-pages-artifact@v3

scripts/fix-llms-urls.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,60 @@
22

33
/**
44
* Script to fix URLs in generated LLMs files to match Docusaurus routing
5-
*
5+
*
66
* This script removes prepended numbers from URLs to match how Docusaurus
77
* generates routes (e.g., "0-overview" becomes "overview")
88
*/
99

10-
const fs = require('fs');
11-
const path = require('path');
10+
const fs = require("fs");
11+
const path = require("path");
1212

1313
const config = {
14-
buildDir: 'build',
15-
filesToFix: ['llms.txt', 'llms-full.txt'],
16-
baseUrl: 'https://dev.flare.network/docs/',
14+
buildDir: "build",
15+
filesToFix: ["llms.txt", "llms-full.txt"],
16+
baseUrl: "https://dev.flare.network/docs/",
1717
};
1818

1919
function fixUrlsInFile(filePath) {
2020
try {
2121
console.log(`Fixing URLs in: ${filePath}`);
22-
23-
const content = fs.readFileSync(filePath, 'utf8');
24-
22+
23+
const content = fs.readFileSync(filePath, "utf8");
24+
2525
// Fix URLs by removing prepended numbers
2626
// Pattern: https://dev.flare.network/docs/network/0-overview -> https://dev.flare.network/docs/network/overview
2727
const fixedContent = content.replace(
2828
/(https:\/\/dev\.flare\.network\/docs\/[^)]+\/)\d+-([^)]+)/g,
29-
'$1$2'
29+
"$1$2",
3030
);
31-
31+
3232
fs.writeFileSync(filePath, fixedContent);
33-
33+
3434
console.log(`✅ Fixed URLs in: ${filePath}`);
35-
3635
} catch (error) {
3736
console.error(`❌ Error fixing URLs in ${filePath}:`, error.message);
3837
}
3938
}
4039

4140
function main() {
42-
console.log('🔧 Fixing URLs in LLMs files...');
43-
41+
console.log("🔧 Fixing URLs in LLMs files...");
42+
4443
if (!fs.existsSync(config.buildDir)) {
4544
console.error(`❌ Build directory not found: ${config.buildDir}`);
4645
return;
4746
}
48-
49-
config.filesToFix.forEach(fileName => {
47+
48+
config.filesToFix.forEach((fileName) => {
5049
const filePath = path.join(config.buildDir, fileName);
51-
50+
5251
if (fs.existsSync(filePath)) {
5352
fixUrlsInFile(filePath);
5453
} else {
5554
console.warn(`⚠️ File not found: ${filePath}`);
5655
}
5756
});
58-
59-
console.log('✅ URL fixing completed!');
57+
58+
console.log("✅ URL fixing completed!");
6059
}
6160

6261
if (require.main === module) {

0 commit comments

Comments
 (0)