Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: loosen frontmatter type and make it configurable #283

Merged
merged 1 commit into from
Jul 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export interface SerializeOptions {
/**
* Represents the return value of a call to serialize()
*/
export type MDXRemoteSerializeResult<TScope = Record<string, unknown>> = {
export type MDXRemoteSerializeResult<
TScope = Record<string, unknown>,
TFrontmatter = Record<string, string>
> = {
/**
* The compiledSource, generated from next-mdx-remote/serialize
*/
Expand All @@ -35,18 +38,5 @@ export type MDXRemoteSerializeResult<TScope = Record<string, unknown>> = {
/**
* If parseFrontmatter was set to true, contains any parsed frontmatter found in the MDX source.
*/
frontmatter?: Frontmatter
frontmatter?: TFrontmatter
}

type Frontmatter =
| null
| boolean
| number
| string
| FrontmatterArray
| FrontmatterObject

// Older versions of typescript do not support recursive inline types; this is a workaround for that.
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#more-recursive-type-aliases
type FrontmatterArray = Array<Frontmatter>;
type FrontmatterObject = { [key: string]: Frontmatter }