-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Update MarkdownContent type #4028
Update MarkdownContent type #4028
Conversation
'url' and 'file' properties were missing in MarkdownContent type, but they should there according to: https://docs.astro.build/en/guides/markdown-content/#markdown-layouts
🦋 Changeset detectedLatest commit: 9340335 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Hi @alfredogonzalezmartinez! Thanks for the PR! Can you share where you're running into this types issue? I think astro/packages/astro/src/@types/astro.ts Lines 779 to 780 in 9340335
|
Hi @natemoo-re, when I want to assign a type to /**
* The `content` prop given to a Layout
*
* [Astro reference](https://docs.astro.build/en/guides/markdown-content/#markdown-layouts)
*/
export declare type MarkdownContent<T extends Record<string, any> = Record<string, any>> = T & {
astro: MarkdownMetadata;
}; But the
---
import { MarkdownContent } from "astro";
interface Frontmatter {
title: string;
}
const content:MarkdownContent<Frontmatter> = Astro.props.content
const {
title,
astro,
url, // Property 'url' does not exist on type 'MarkdownContent<Frontmatter>'.ts(2339)
file // Property 'file' does not exist on type 'MarkdownContent<Frontmatter>'.ts(2339)
} = content
--- Example of content prop output In the release [email protected], the PR #3588 adds |
Makes sense, thanks! |
Changes
url
andfile
properties toMarkdownContent
typeTesting
N/A
Docs
Current docs indicates that
MarkdownContent
type should have propertiesurl
andfile
.