Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: troubleshooting sync script (#32806)

Charis31e21d551801
diff --git a/apps/docs/features/docs/Troubleshooting.script.mjs b/apps/docs/features/docs/Troubleshooting.script.mjs
index 698525aaea3..cd13d7d48c9 100644
--- a/apps/docs/features/docs/Troubleshooting.script.mjs
+++ b/apps/docs/features/docs/Troubleshooting.script.mjs
@@ -125,7 +125,7 @@ async function syncTroubleshootingEntries() {
if (result.status === 'rejected') {
console.error(
`[ERROR] Failed to insert and/or update for ${troubleshootingEntries[index].filePath}:\n%O`,
- result.reason
+ result.reason?.errors ?? result.reason
)
hasErrors = true
}
@@ -169,7 +169,14 @@ function calculateChecksum(content) {
extensions: [gfm(), mdxjs()],
mdastExtensions: [gfmFromMarkdown(), mdxFromMarkdown()],
})
- const normalized = toMarkdown(mdast, { extensions: [gfmToMarkdown(), mdxToMarkdown()] })
+ const bodyNormalized = toMarkdown(mdast, { extensions: [gfmToMarkdown(), mdxToMarkdown()] })
+
+ const { data, content: body } = matter(bodyNormalized, {
+ language: 'toml',
+ engines: { toml: toml.parse.bind(toml) },
+ })
+ const newFrontmatter = stringify(data)
+ const normalized = `---\n${newFrontmatter}\n---\n${body}`
return createHash('sha256').update(normalized).digest('base64')
}
@@ -261,12 +268,19 @@ function addCanonicalUrl(entry) {
return content
}
+/**
+ * @param {string} str
+ */
+function escapeGraphQlString(str) {
+ return str.replace(/"/g, '\\"')
+}
+
/**
* @param {TroubleshootingEntry} entry
*/
async function createGithubDiscussion(entry) {
console.log(`[INFO] Creating GitHub discussion for ${entry.data.title}`)
- const content = addCanonicalUrl(entry)
+ const content = escapeGraphQlString(addCanonicalUrl(entry))
const mutation = `
mutation {
@@ -364,7 +378,7 @@ async function updateGithubDiscussion(entry) {
throw error
}
- const content = addCanonicalUrl(entry)
+ const content = escapeGraphQlString(addCanonicalUrl(entry))
const mutation = `
mutation {
updateDiscussion(input: {