site: add frontmatter parsing support

This commit is contained in:
Glen Huang
2025-10-06 21:33:54 +08:00
committed by Johannes Kirschbauer
parent 7112f608a7
commit 84ab04fc06
6 changed files with 1466 additions and 11 deletions

View File

@@ -1,6 +1,16 @@
<script lang="ts">
let { data } = $props();
let { content } = data;
let { content, toc, frontmatter } = data;
</script>
<div class="toc">
{@html toc}
</div>
{@html content}
{JSON.stringify(frontmatter)}
<style>
.toc :global(p) {
margin: 0;
}
</style>

View File

@@ -3,6 +3,8 @@ import type { Component } from "svelte";
const articles = import.meta.glob<{
default: string;
frontmatter: {};
toc: {};
}>("../**/*.md");
export async function load({ params }) {
@@ -11,8 +13,10 @@ export async function load({ params }) {
error(404, "");
}
const content = await article();
const { frontmatter, toc, default: content } = await article();
return {
content: content.default,
content,
frontmatter,
toc,
};
}

View File

@@ -1 +1,6 @@
---
a: 1
b: 2
---
# Getting Started Overview