Files
supabase/apps/docs/lib/mdx/generateRefMarkdown.tsx
T
Ivan VasilovandClaude Haiku 4.5 3a98d32b6e chore: upgrade next-mdx-remote to v6 in apps/docs (#42748)
## I have read the CONTRIBUTING.md file.

YES

## What kind of change does this PR introduce?

Dependency upgrade (next-mdx-remote v4 → v6)

## What is the current behavior?

The docs app uses next-mdx-remote v4.4.1 with MDX v2.

## What is the new behavior?

- Upgraded to next-mdx-remote v6.0.0 (uses MDX v3)
- Updated @mdx-js/loader and @mdx-js/react to v3
- Upgraded remark-gfm to v4 for MDX v3 compatibility
- Removed deprecated `useDynamicImport` option (now default)
- Added `blockJS: false` to preserve JS expressions in MDX content

Build compiles successfully. Testing shows the same pre-existing
prerender error on /guides/troubleshooting as on master (supabaseUrl is
required).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Upgraded MDX and markdown tooling to major releases (MDX v3,
next-mdx-remote v6, remark-gfm v4).
* Adjusted MDX serialization to disable embedded JS handling and remove
legacy dynamic-import behavior for more consistent rendering of docs,
guides, and code examples.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-12 19:01:53 +00:00

59 lines
1.6 KiB
TypeScript

import fs from 'fs'
import codeHikeTheme from 'config/code-hike.theme.json' with { type: 'json' }
import matter from 'gray-matter'
import { serialize } from 'next-mdx-remote/serialize'
import remarkGfm from 'remark-gfm'
import type { ICommonMarkdown } from '~/components/reference/Reference.types'
async function generateRefMarkdown(sections: ICommonMarkdown[], slug: string) {
let markdownContent: any[] = []
/**
* Read all the markdown files that might have
* - custom text
* - call outs
* - important notes regarding implementation
*/
await Promise.all(
sections.map(async (section) => {
const pathName = `docs/ref${slug}/${section.id}.mdx`
function checkFileExists(x) {
if (fs.existsSync(x)) {
return true
} else {
return false
}
}
const markdownExists = checkFileExists(pathName)
if (!markdownExists) return null
const fileContents = markdownExists ? fs.readFileSync(pathName, 'utf8') : ''
const { data, content } = matter(fileContents)
markdownContent.push({
id: section.id,
title: section.title,
meta: data,
// introPage: introPages.includes(x),
content: content
? await serialize(content ?? '', {
blockJS: false,
// MDX's available options, see the MDX docs for more info.
// https://mdxjs.com/packages/mdx/#compilefile-options
mdxOptions: {
remarkPlugins: [remarkGfm],
},
})
: null,
})
})
)
return markdownContent
}
export default generateRefMarkdown