Skip to content

Commit

Permalink
Add references to TOML frontmatter support
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbate committed Jan 22, 2025
1 parent dc9b3fc commit 52ec20a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/content/docs/en/guides/imports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ Markdown files loaded with `import.meta.glob()` return the following `MarkdownIn

```ts
export interface MarkdownInstance<T extends Record<string, any>> {
/* Any data specified in this file's YAML frontmatter */
/* Any data specified in this file's YAML/TOML frontmatter */
frontmatter: T;
/* The absolute file path of this file */
file: string;
/* The rendered path of this file */
url: string | undefined;
/* Astro Component that renders the contents of this file */
Content: AstroComponentFactory;
/** (Markdown only) Raw Markdown file content, excluding layout HTML and YAML frontmatter */
/** (Markdown only) Raw Markdown file content, excluding layout HTML and YAML/TOML frontmatter */
rawContent(): string;
/** (Markdown only) Markdown file compiled to HTML, excluding layout HTML */
compiledContent(): string;
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/guides/integrations-guide/mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ The following properties are available to a `.astro` component when using an `im

- **`file`** - The absolute file path (e.g. `/home/user/projects/.../file.mdx`).
- **`url`** - The URL of the page (e.g. `/en/guides/markdown-content`).
- **`frontmatter`** - Contains any data specified in the file’s YAML frontmatter.
- **`frontmatter`** - Contains any data specified in the file’s YAML/TOML frontmatter.
- **`getHeadings()`** - An async function that returns an array of all headings (`<h1>` to `<h6>`) in the file with the type: `{ depth: number; slug: string; text: string }[]`. Each heading’s `slug` corresponds to the generated ID for a given heading and can be used for anchor links.
- **`<Content />`** - A component that returns the full, rendered contents of the file.
- **(any `export` value)** - MDX files can also export data with an `export` statement.
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/en/guides/markdown-content.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import RecipeLinks from "~/components/RecipeLinks.astro";
import ReadMore from '~/components/ReadMore.astro';
import { Steps } from '@astrojs/starlight/components';

[Markdown](https://daringfireball.net/projects/markdown/) is commonly used to author text-heavy content like blog posts and documentation. Astro includes built-in support for Markdown files that can also include [frontmatter YAML](https://dev.to/paulasantamaria/introduction-to-yaml-125f) to define custom properties such as a title, description, and tags.
[Markdown](https://daringfireball.net/projects/markdown/) is commonly used to author text-heavy content like blog posts and documentation. Astro includes built-in support for Markdown files that can also include [frontmatter YAML](https://dev.to/paulasantamaria/introduction-to-yaml-125f) (or [TOML](https://toml.io)) to define custom properties such as a title, description, and tags.

In Astro, you can author content in [GitHub Flavored Markdown](https://github.github.com/gfm/), then render it in `.astro` components. This combines a familiar writing format designed for content with the flexibility of Astro's component syntax and architecture.

Expand Down Expand Up @@ -79,7 +79,7 @@ The following exported properties are available in your `.astro` component when

- **`file`** - The absolute file path (e.g. `/home/user/projects/.../file.md`).
- **`url`** - The URL of the page (e.g. `/en/guides/markdown-content`).
- **`frontmatter`** - Contains any data specified in the file’s YAML frontmatter.
- **`frontmatter`** - Contains any data specified in the file’s YAML (or TOML) frontmatter.
- **`<Content />`** - A component that returns the full, rendered contents of the file.
- **`rawContent()`** - A function that returns the raw Markdown document as a string.
- **`compiledContent()`** - An async function that returns the Markdown document compiled to an HTML string.
Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/en/guides/migrate-to-astro/from-hugo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Hugo and Astro share some similarities that will help you migrate your project:

- Hugo and Astro are both modern static-site generators, ideally suited to [content-driven websites](/en/concepts/why-astro/#content-driven) like blogs.

- Hugo and Astro both allow you to [author your content in Markdown](/en/guides/markdown-content/). However, Hugo includes several special frontmatter properties and allows you to write frontmatter in YAML, TOML or JSON. Even though many of your existing Hugo frontmatter properties will not be "special" in Astro, you can continue to use your existing Markdown files and YAML frontmatter values.
- Hugo and Astro both allow you to [author your content in Markdown](/en/guides/markdown-content/). However, Hugo includes several special frontmatter properties and allows you to write frontmatter in YAML, TOML or JSON. Even though many of your existing Hugo frontmatter properties will not be "special" in Astro, you can continue to use your existing Markdown files and YAML (or TOML) frontmatter values.

- Hugo and Astro both allow you to enhance your site with a variety of [integrations and external packages](https://astro.build/integrations/).

Expand Down Expand Up @@ -59,9 +59,9 @@ You can pass a `--template` argument to the `create astro` command to start a ne
</Fragment>
</PackageManagerTabs>

Bring your existing Markdown (or MDX, with our optional integration) files as content to [create Markdown or MDX pages](/en/guides/markdown-content/). You may need to convert your frontmatter to YAML, since Astro only allows YAML frontmatter in these files.
Bring your existing Markdown (or MDX, with our optional integration) files as content to [create Markdown or MDX pages](/en/guides/markdown-content/). Astro allows YAML or TOML frontmatter in these files, so if you are using JSON frontmatter, you will need to convert it.

To continue to use dynamic content such as variables, expressions or UI components within your Markdown content, add Astro's optional MDX integration and convert your existing Markdown files to [MDX pages](/en/guides/markdown-content/). MDX supports YAML frontmatter, so you can keep your existing frontmatter properties. But, you must replace any shortcode syntax with [MDX's own syntax](https://mdxjs.com/docs/what-is-mdx/#mdx-syntax), which allows JSX expressions and/or component imports.
To continue to use dynamic content such as variables, expressions or UI components within your Markdown content, add Astro's optional MDX integration and convert your existing Markdown files to [MDX pages](/en/guides/markdown-content/). MDX supports YAML and TOML frontmatter, so you can keep your existing frontmatter properties. But, you must replace any shortcode syntax with [MDX's own syntax](https://mdxjs.com/docs/what-is-mdx/#mdx-syntax), which allows JSX expressions and/or component imports.

To convert other types of sites, such as a portfolio or documentation site, see more official starter templates on [astro.new](https://astro.new). You'll find a link to each project's GitHub repository, as well as one-click links to open a working project in IDX, StackBlitz, CodeSandbox and Gitpod online development environments.

Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/en/reference/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -880,15 +880,15 @@ Markdown files loaded with `Astro.glob()` return the following `MarkdownInstance

```ts
export interface MarkdownInstance<T extends Record<string, any>> {
/* Any data specified in this file's YAML frontmatter */
/* Any data specified in this file's YAML/TOML frontmatter */
frontmatter: T;
/* The absolute file path of this file */
file: string;
/* The rendered path of this file */
url: string | undefined;
/* Astro Component that renders the contents of this file */
Content: AstroComponentFactory;
/** (Markdown only) Raw Markdown file content, excluding layout HTML and YAML frontmatter */
/** (Markdown only) Raw Markdown file content, excluding layout HTML and YAML/TOML frontmatter */
rawContent(): string;
/** (Markdown only) Markdown file compiled to HTML, excluding layout HTML */
compiledContent(): string;
Expand Down

0 comments on commit 52ec20a

Please sign in to comment.