mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 22:18:00 +08:00
Render blog posts on server so they are available in initial HTML response. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * New collapsible sections for blog content * Server-side MDX compilation for blog posts * Improved TOC extraction producing both structured JSON and markdown * **Refactor** * Blog rendering converted to a server-rendered flow with unified MDX components * Tag handling normalized for related-post matching * **Bug Fixes** * Consistent image/self-closing tag normalization and corrected TOC indentation * Errors are now surfaced instead of being swallowed <!-- end of auto-generated comment: release notes by coderabbit.ai -->
23 lines
689 B
TypeScript
23 lines
689 B
TypeScript
import { compile, run } from '@mdx-js/mdx'
|
|
import type { ReactElement } from 'react'
|
|
import * as runtime from 'react/jsx-runtime'
|
|
|
|
import { mdxOptionsBlog } from './mdxOptionsBlog'
|
|
|
|
export async function compileBlogMdx(
|
|
source: string,
|
|
components: Record<string, unknown>
|
|
): Promise<ReactElement> {
|
|
const compiled = await compile(source, {
|
|
outputFormat: 'function-body',
|
|
development: false,
|
|
remarkPlugins: mdxOptionsBlog.remarkPlugins,
|
|
rehypePlugins: mdxOptionsBlog.rehypePlugins,
|
|
})
|
|
const { default: MDXContent } = await run(String(compiled), {
|
|
...(runtime as any),
|
|
baseUrl: import.meta.url,
|
|
})
|
|
return MDXContent({ components: components as any })
|
|
}
|