MCPcopy Create free account
hub / github.com/Drakkar-Software/OctoBot / adaptLinks

Function adaptLinks

docs/scripts/sync-root-docs.mjs:55–64  ·  view source on GitHub ↗

Adapt relative links to work within the docs site or fall back to GitHub URLs.

(content)

Source from the content-addressed store, hash-verified

53
54/** Adapt relative links to work within the docs site or fall back to GitHub URLs. */
55function adaptLinks(content) {
56 return content
57 // Known root-level docs → docs site paths
58 .replace(/\[([^\]]+)\]\(\.\/packages\/README\.md\)/g, '[$1](/developers/packages/overview)')
59 .replace(/\[([^\]]+)\]\(\.\/CONTRIBUTING\.md\)/g, '[$1](/developers/contributing)')
60 .replace(/\[([^\]]+)\]\(\.\/CHANGELOG\.md\)/g, '[$1](/developers/changelog)')
61 // Remaining relative .md links → GitHub source URLs
62 .replace(/\[([^\]]+)\]\(\.\/((?!http)[^)]+\.md)\)/g,
63 `[$1](https://github.com/Drakkar-Software/OctoBot/blob/${DEFAULT_BRANCH}/$2)`);
64}
65
66async function main() {
67 console.log('Syncing root documentation files...');

Callers 1

mainFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected