rules:
- name: "Astro Frontmatter Rules"
description: "Guidelines for writing valid Astro frontmatter in .astro files."
content: |
- Always place frontmatter at the very top of the file.
- Use triple dashes (---) to open and close the block.
- Only one frontmatter block per .astro file.
- Use frontmatter for:
- Imports
- Declaring constants and variables
- Exporting metadata with
export const
- Accessing Astro.props in components
- Async data fetching (using await)
- Do NOT:
- Use DOM APIs (document, window)
- Add client-side scripts here
-
Everything exported becomes available in the template:
Example:
export const title = "OSS Communities";
<h1>{title}</h1>
-
For components, destructure props from Astro.props:
const { heading } = Astro.props;
- Keep heavy logic outside frontmatter (move to utility files).