Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions scripts/fix-llms-urls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function rewritePaths(content, replacements) {
* unlistedPaths)
* - append `.md` to the URL when the target is a documentation route
*/
function pruneAndMarkdownify(content, canonicalRoutes) {
function pruneAndMarkdownify(content, canonicalRoutes, unlistedPaths) {
const linkRe = /\[([^\]]+)\]\((https:\/\/dev\.flare\.network\/[^)]+)\)/g;

// Process line-by-line so we can drop entire bullet lines whose URL is stale.
Expand All @@ -230,6 +230,10 @@ function pruneAndMarkdownify(content, canonicalRoutes) {
// Dropped — stale or unlisted.
continue;
}
if (unlistedPaths.has(route)) {
// Dropped — explicitly unlisted in frontmatter.
continue;
}
}

// Otherwise: keep the line, but rewrite same-origin doc links to .md.
Expand Down Expand Up @@ -332,12 +336,13 @@ function processLlmsTxt(
filePath,
replacements,
canonicalRoutes,
unlistedPaths,
titleByRoute,
isIndex,
) {
const original = fs.readFileSync(filePath, "utf8");
let content = rewritePaths(original, replacements);
content = pruneAndMarkdownify(content, canonicalRoutes);
content = pruneAndMarkdownify(content, canonicalRoutes, unlistedPaths);
if (isIndex) {
content = appendMissingRoutes(content, canonicalRoutes, titleByRoute);
}
Expand All @@ -352,7 +357,7 @@ function main() {
console.warn("[fix-llms-urls] build/ not found, skipping.");
return;
}
const { replacements } = buildReplacementsAndUnlisted();
const { replacements, unlistedPaths } = buildReplacementsAndUnlisted();
const canonicalRoutes = loadCanonicalRoutes();
// Always allow the home route (`/` -> `https://dev.flare.network` with no
// trailing slash). Add it explicitly so links to root pass.
Expand All @@ -379,6 +384,7 @@ function main() {
path.join(buildDir, e.name),
replacements,
canonicalRoutes,
unlistedPaths,
titleByRoute,
isIndex,
);
Expand Down