(filePath: string)
| 15 | } |
| 16 | |
| 17 | export async function parse(filePath: string) { |
| 18 | const template = await Bun.file(filePath).text() |
| 19 | |
| 20 | try { |
| 21 | const md = matter(template) |
| 22 | return md |
| 23 | } catch (err) { |
| 24 | throw new FrontmatterError( |
| 25 | { |
| 26 | path: filePath, |
| 27 | message: `Failed to parse YAML frontmatter: ${err instanceof Error ? err.message : String(err)}`, |
| 28 | }, |
| 29 | { cause: err }, |
| 30 | ) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | export const FrontmatterError = NamedError.create( |
| 35 | "ConfigFrontmatterError", |