Skip to content

Commit

Permalink
Consistent MD frontmatter typing (#5294)
Browse files Browse the repository at this point in the history
* consistent MD frontmatter typing

* changeset
  • Loading branch information
mrienstra committed Nov 10, 2022
1 parent edfbb0c commit ae41f25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-trains-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Consistent Markdown frontmatter typing (`MarkdownAstroData["frontmatter"]` in particular was `object` before)
10 changes: 6 additions & 4 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -1083,9 +1085,7 @@ export interface ManifestData {
}

export interface MarkdownParserResponse extends MarkdownRenderingResult {
frontmatter: {
[key: string]: any;
};
frontmatter: MD['frontmatter'];
}

/**
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ae41f25

Please sign in to comment.