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