diff --git a/src/pages/en/core-concepts/layouts.md b/src/pages/en/core-concepts/layouts.md index 6b00b5a1c689d..4892d9fdc574f 100644 --- a/src/pages/en/core-concepts/layouts.md +++ b/src/pages/en/core-concepts/layouts.md @@ -68,19 +68,19 @@ description: My first blog post! This is a post written in Markdown. ``` -When a Markdown file includes a layout, it passes a `content` property to the `.astro` component which includes the frontmatter properties and the final HTML output of the page. +When a Markdown file includes a layout, it passes a `frontmatter` property to the `.astro` component which includes the frontmatter properties and the final HTML output of the page. **`src/layouts/BlogPostLayout.astro`** -```astro /content(?:.\w+)?/ +```astro /frontmatter(?:.\w+)?/ --- -const {content} = Astro.props; +const {frontmatter} = Astro.props; --- -
Written on: {content.date}
+Written on: {frontmatter.date}
``` @@ -78,9 +78,9 @@ Markdown and MDX files do not return identical `Astro.props` objects. See the MD A Markdown layout will have access to the following information via `Astro.props`: -- **`content`** - all frontmatter from the Markdown or MDX document. - - **`content.file`** - The absolute path of this file (e.g. `/home/user/projects/.../file.md`). - - **`content.url`** - If it's a page, the URL of the page (e.g. `/en/guides/markdown-content`). +- **`frontmatter`** - all frontmatter from the Markdown or MDX document. + - **`frontmatter.file`** - The absolute path of this file (e.g. `/home/user/projects/.../file.md`). + - **`frontmatter.url`** - If it's a page, the URL of the page (e.g. `/en/guides/markdown-content`). - **`headings`** - A list of headings (`h1 -> h6`) in the Markdown document with associated metadata. This list follows the type: `{ depth: number; slug: string; text: string }[]`. - **`rawContent()`** - A function that returns the raw Markdown document as a string. - **`compiledContent()`** - A function that returns the Markdown document compiled to an HTML string. @@ -89,7 +89,7 @@ An example blog post may pass the following `Astro.props` object to its layout: ```js Astro.props = { - content: { + frontmatter: { /** Frontmatter from a blog post */ title: "Astro 0.18 Release", date: "Tuesday, July 27 2021", @@ -119,14 +119,14 @@ Astro.props = { #### Example: Using one Layout that works for `.md`, `.mdx`, and `.astro` files -A single Astro layout can be written to receive the content object from `.md` and `.mdx` files, as well as any named props passed from `.astro` files. +A single Astro layout can be written to receive the `frontmatter` object from `.md` and `.mdx` files, as well as any named props passed from `.astro` files. In the example below, the layout will display the page title either from an Astro component passing a `title` attribute or from a frontmatter YAML `title` property: ```astro /{?title}?/ /Astro.props[.a-z]*/ --- // src/components/MyLayout.astro -const { title } = Astro.props.content || Astro.props; +const { title } = Astro.props.frontmatter || Astro.props; --- @@ -467,9 +467,9 @@ export default { ...all Markdown documents will have a calculated `minutesRead`. You can use this to include an "X min read" banner in a [markdown layout](#markdown-and-mdx-pages), for instance: -```astro title="src/layouts/BlogLayout.astro" "const { minutesRead } = Astro.props.content;" "{minutesRead}
" +```astro title="src/layouts/BlogLayout.astro" "const { minutesRead } = Astro.props.frontmatter;" "{minutesRead}
" --- -const { minutesRead } = Astro.props.content; +const { minutesRead } = Astro.props.frontmatter; ---