Consistent MD frontmatter typing (#5294)

* consistent MD frontmatter typing

* changeset
This commit is contained in:
Michael Rienstra 2022-11-10 14:54:34 -08:00 committed by GitHub
parent edfbb0c9dd
commit ae41f25e10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Consistent Markdown frontmatter typing (`MarkdownAstroData["frontmatter"]` in particular was `object` before)

View file

@ -1005,6 +1005,8 @@ export interface MarkdownInstance<T extends Record<string, any>> {
default: AstroComponentFactory;
}
type MD = MarkdownInstance<Record<string, any>>;
export interface MDXInstance<T extends Record<string, any>>
extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> {
/** MDX does not support rawContent! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
@ -1083,9 +1085,7 @@ export interface ManifestData {
}
export interface MarkdownParserResponse extends MarkdownRenderingResult {
frontmatter: {
[key: string]: any;
};
frontmatter: MD['frontmatter'];
}
/**
@ -1410,7 +1410,9 @@ export interface SSRResult {
_metadata: SSRMetadata;
}
export type MarkdownAstroData = { frontmatter: object };
export type MarkdownAstroData = {
frontmatter: MD['frontmatter'];
};
/* Preview server stuff */
export interface PreviewServer {