Default Frontmatter
frontmatter: boolean | string;
Merge YAML frontmatter files into the frontmatter of MDX files.
- default:
false
, no frontmatter is merged true
, to enable frontmatter merging from files with name_frontmatter.yaml
<name>
, to find frontmatter in YAML files named<name>
Now you can create frontmatter YAML files with the defined name in your src
directory to define common properties.
All files up the directory tree are merged into the frontmatter, with values from the files frontmatter taking highest precedence and values from frontmatter files furthest up the tree taking least precedence. Object properties will be deeply merged, Array
, Date
and Regex
objects will not be merged.
A very simple frontmatter file defining a default layout for all MDX files in a directory:
layout: @layouts/BlogLayout.astro
⚠️ Beware of relative references inside these files: The values are merged as-is and hence will be relative to the receiving MDX file and not the default frontmatter-file. It is safer to define
paths
in your tsconfig.json.