(path)
| 1 | import fm from "front-matter"; |
| 2 | |
| 3 | export async function parseMarkdown(path) { |
| 4 | const response = await fetch(path); |
| 5 | |
| 6 | if (!response.ok) { |
| 7 | throw new Error(`Failed to load ${path}: ${response.status}`); |
| 8 | } |
| 9 | |
| 10 | const raw = await response.text(); |
| 11 | const parsed = fm(raw); |
| 12 | |
| 13 | return { |
| 14 | frontmatter: parsed.attributes, |
| 15 | content: parsed.body |
| 16 | }; |
| 17 | } |