Markdown

Markdown s'utilitza habitualment per crear contingut ric en text, com entrades de blog i documentació.

Introducció

Markdown s’utilitza habitualment per crear contingut ric en text, com entrades de blog i documentació.

Astro inclou suport integrat per a fitxers Markdown que també poden incloure frontmatter YAML (o TOML) per definir propietats personalitzades com un títol, descripció o tags.

Astro also treats any Markdown (.md) files inside of src/pages/ as pages in your final website. If you have the MDX Integration installed, it also treats MDX (.mdx) files the same way.

Markdown files can use the special layout frontmatter property to specify a layout component that will wrap their Markdown content in a full <html>...</html> page document.

TODO

Organizing Markdown files

Your local Markdown files can be kept anywhere within your src/ directory. Markdown files located within src/pages/ will automatically generate Markdown pages on your site.

Your Markdown content and frontmatter properties are available to use in components through local file imports or when queried and rendered from data fetched by a content collections helper function.

Local Markdown can be imported into .astro components using an import statement for a single file and Vite’s import.meta.glob() to query multiple files at once. The exported data from these Markdown files can then be used in the .astro component.

Layouts

Page layouts are especially useful for individual Markdown pages which otherwise would not have any page formatting.

Astro provides a special layout frontmatter property intended for individual .mdx files located within src/pages/ using file-based routing to specify which .astro component to use as the page layout.

This component allows you to provide <head> content like meta tags (e.g. <meta charset="utf-8">) and styles for the Markdown page. By default, this specified component can automatically access data from the Markdown file.

Markdown Layouts

TODO