Skip to content

Commit 3803a49

Browse files
committed
fix(docs): add path transformation to ignore 'docs' directory in Docusaurus config and improve URL fixing logic in script
1 parent ec8f071 commit 3803a49

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

docusaurus.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ const config: Config = {
266266
{
267267
// scope
268268
docsDir: "docs",
269+
// URLs: we use routeBasePath "/" so docs are at root, not /docs
270+
pathTransformation: {
271+
ignorePaths: ["docs"],
272+
},
269273
// outputs
270274
generateLLMsTxt: true,
271275
generateLLMsFullTxt: true,

scripts/fix-llms-urls.mjs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,17 @@ function buildReplacements() {
111111
function fixFile(filePath, replacements) {
112112
let content = fs.readFileSync(filePath, "utf8");
113113
let changed = false;
114+
const rightUrlBase = `${SITE_BASE}/`;
114115
for (const [wrongPath, rightPath] of replacements) {
115-
const wrongUrl = `${SITE_BASE}/${wrongPath}`;
116-
const rightUrl = `${SITE_BASE}/${rightPath}`;
117-
const re = new RegExp(escapeRe(wrongUrl) + "(?!/)", "g");
118-
const next = content.replace(re, rightUrl);
119-
if (next !== content) {
120-
content = next;
121-
changed = true;
116+
const rightUrl = rightUrlBase + rightPath;
117+
for (const prefix of ["", "docs/"]) {
118+
const wrongUrl = rightUrlBase + prefix + wrongPath;
119+
const re = new RegExp(escapeRe(wrongUrl) + "(?!/)", "g");
120+
const next = content.replace(re, rightUrl);
121+
if (next !== content) {
122+
content = next;
123+
changed = true;
124+
}
122125
}
123126
}
124127
if (changed) {

0 commit comments

Comments
 (0)