From e97ca89ab15317c037bf0196919ecd3371ad26a9 Mon Sep 17 00:00:00 2001 From: Charis <26616127+charislam@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:22:13 -0500 Subject: [PATCH] fix: troubleshooting sync (#33908) Relative links don't make sense in GitHub discussions so they need to be converted to absolute links for syncing. --- .../docs/Troubleshooting.utils.common.mjs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/docs/features/docs/Troubleshooting.utils.common.mjs b/apps/docs/features/docs/Troubleshooting.utils.common.mjs index 12c275a08e0..2463eb7709e 100644 --- a/apps/docs/features/docs/Troubleshooting.utils.common.mjs +++ b/apps/docs/features/docs/Troubleshooting.utils.common.mjs @@ -158,7 +158,12 @@ export async function getAllTroubleshootingEntriesInternal() { ].includes(child.type) ) } + + if (node.type === 'link' || node.type === 'image') { + canonicalizeUrl(node) + } }) + const contentWithoutJsx = toMarkdown(mdxTree, { extensions: [gfmToMarkdown()], }) @@ -174,6 +179,16 @@ export async function getAllTroubleshootingEntriesInternal() { return (await Promise.all(troubleshootingFiles)).filter((x) => x != null) } +/** + * + * @param {import('mdast').Image | import('mdast').Link} node + */ +function canonicalizeUrl(node) { + if (node.url.startsWith('/')) { + node.url === 'https://supabase.com' + node.url + } +} + /** * @param {TroubleshootingEntry} entry */