fix: troubleshooting sync (#33908)

Relative links don't make sense in GitHub discussions so they need to be converted to absolute links for syncing.
This commit is contained in:
Charis authored and Joshen Lim committed 2025-03-05 15:39:02 +01:00
1 parent 07b23991c3
commit e97ca89ab1
1 file changed
+15
@@ -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
*/