v4.4.0
This release includes a few fixes for frontmatter types, as well as a way to provide a frontmatter type to serialize
or compileMDX
and have it propagate through to the returned frontmatter
property. See the documentation for an example.
serialize
:
import { serialize } from 'next-mdx-remote/serialize'
interface Frontmatter {
title: string
published: string
description?: string
}
// π should have type Frontmatter
const { frontmatter } = serialize<Record<string, unknown>, Frontmatter>(source)
compileMDX
:
import { compileMDX } from 'next-mdx-remote/rsc'
interface Frontmatter {
title: string
published: string
description?: string
}
export default async function Page({ source }) {
// π should have type Frontmatter
const { content, frontmatter } = await compileMDX<Frontmatter>(source)
return (
<>
<h1>{frontmatter.title}</h1>
{content}
</>
)
}
What's Changed
- docs: fix react server components example by @greyhere in #334
- fix(rsc): do not require compiledSource in types by @BRKalow in #339
- fix: TFrontmatter type to unknown by @RebootGG in #340
- remove newline from template literal by @chrisweb in #346
- feat: Improve frontmatter types, pass generic TFrontmatter type through by @BRKalow in #342
New Contributors
- @greyhere made their first contribution in #334
- @RebootGG made their first contribution in #340
- @chrisweb made their first contribution in #346
Full Changelog: v4.3.0...v4.4.0