Frontmatter
Frontmatter in markdown
Use yaml format at the beginning of your md file.
---
title: Some title
description: some description
--- md
Frontmatter in svelte
Export a const variable name as frontmatter in Svelte script module would do
/src/routes/foo/+page.svelte
<script module>
export const = {
: 'Some title',
: 'Some description',
}
</script> svelte
Accessing frontmatter in markdown
Use fm variable:
Frontmatter of this page is:
{
"pageType": "md",
"lastUpdate": "2024/12/08 05:00:59",
"anchors": [
{
"slugId": "Frontmatter-in-markdown",
"title": "Frontmatter in markdown",
"depth": 2
},
{
"slugId": "Frontmatter-in-svelte",
"title": "Frontmatter in svelte",
"depth": 2
},
{
"slugId": "Accessing-frontmatter-in-markdown",
"title": "Accessing frontmatter in markdown",
"depth": 2
},
{
"slugId": "Site-frontmatter",
"title": "Site frontmatter",
"depth": 2
}
],
"title": "Frontmatter"
}
Frontmatter of this page is:
<pre>
{JSON.stringify(fm, null, 2)}
</pre> md
Click fold/expand code
Site frontmatter
The global shared frontmatter for every +page.md file
interface SiteConfig {
?: string
?: string
} ts