site: add frontmatter parsing support
This commit is contained in:
committed by
Johannes Kirschbauer
parent
7112f608a7
commit
84ab04fc06
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
---
|
||||
a: 1
|
||||
b: 2
|
||||
---
|
||||
|
||||
# Getting Started Overview
|
||||
|
||||
Reference in New Issue
Block a user