Skip to content

v4.4.0

Compare
Choose a tag to compare
@BRKalow BRKalow released this 28 Feb 15:43
· 22 commits to main since this release

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

Full Changelog: v4.3.0...v4.4.0