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 context module
would do

/src/routes/foo/+page.svelte
<script context="module">
  export const  = {
    : 'Some title',
    : 'Some description'
  }
pt>
svelte

Accessing frontmatter in markdown

Use fm variable:

Frontmatter of this page is:

{
  "pageType": "md",
  "lastUpdate": "2023/06/29 08:11:13",
  "title": "Frontmatter",
  "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
    }
  ]
}
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
Last update at: 2023/06/29 08:11:13