Sierra guide / Routing
Frontmatter
A block at the top of a .mesa or .md file describes the page: its title, whether it prerenders, where it redirects. Keys Sierra does not act on are yours and are spread onto page.
import { parseFrontmatter } from '@frontierjs/sierra/scanner'
const source = `---
title: Pricing
render: static
robots: noindex
---
<h1>Pricing</h1>`
const { frontmatter, content } = parseFrontmatter(source)
if (frontmatter.title !== 'Pricing' || frontmatter.render !== 'static') throw new Error(`unexpected ${JSON.stringify(frontmatter)}`)
if (content !== '<h1>Pricing</h1>') throw new Error(`unexpected body ${content}`)
What else it can do
reset: truerenders the route with no layoutrender: staticmakes a page that cannot prerender fail astaticbuild, andrender: spaleaves it to the browserredirect: /path/redirects a navigation there and is also written to_redirectsstatus: draftleaves the page out ofpublishedandindexedrobots: noindexleaves it out ofindexedand the sitemapsiteName: My Appbecomes{page.siteName}- The merge order is layout frontmatter, layout
.meta.js, route.meta.js, route frontmatter, then system flags, and the rightmost wins - The syntax is a YAML subset, with no anchors, aliases or tags, and a date stays a string
- A key named like a router field, such as
paramsordata, is shadowed and the scanner warns
In depth: Sierra README § Frontmatter