From fe5a589f6b56cbafe8f3153552cad7c5bf9ba13e Mon Sep 17 00:00:00 2001 From: Alex Stephen <1325798+rambleraptor@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:54:17 -0700 Subject: [PATCH] link fix (#13) --- scripts/generate.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/generate.ts b/scripts/generate.ts index 3935530..6cea820 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -139,9 +139,18 @@ function buildMarkdown(contents: string, folder: string): Markdown { substituteCallouts(result); substituteRuleIdentifiers(result); removeTitle(result); + substituteLinks(result); return result; } +function substituteLinks(contents: Markdown) { + // Old site-generator expressed relative links as '[link]: ./0123'. + // These should be expressed as '[link]: /123' + + contents.contents = contents.contents.replaceAll(']: ./', ']: /') + contents.contents = contents.contents.replaceAll(']: /0', ']: /') +} + function removeTitle(contents: Markdown) { // Title should be removed because Starlight will add it for us. contents.contents = contents.contents.replace(/# (.*)\n/, '');