(markdown)
| 235 | } |
| 236 | |
| 237 | export function parseFrontmatter(markdown) { |
| 238 | const extracted = extractFrontmatter(markdown); |
| 239 | if (extracted.errors.length > 0) { |
| 240 | return { |
| 241 | data: null, |
| 242 | body: extracted.body, |
| 243 | errors: extracted.errors, |
| 244 | }; |
| 245 | } |
| 246 | |
| 247 | try { |
| 248 | const parsed = parseYamlDocument(extracted.frontmatterText); |
| 249 | return { |
| 250 | data: parsed, |
| 251 | body: extracted.body, |
| 252 | errors: [], |
| 253 | }; |
| 254 | } catch (error) { |
| 255 | return { |
| 256 | data: null, |
| 257 | body: extracted.body, |
| 258 | errors: [error instanceof Error ? error.message : String(error)], |
| 259 | }; |
| 260 | } |
| 261 | } |
no test coverage detected