Home / Function/ safeParseFrontmatter() — astro Function Reference

safeParseFrontmatter() — astro Function Reference

Architecture documentation for the safeParseFrontmatter() function in utils.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  fc662a49_04f8_23d0_0af0_44d9054f333e["safeParseFrontmatter()"]
  7a09e708_c090_71c0_8138_7343699b1865["utils.ts"]
  fc662a49_04f8_23d0_0af0_44d9054f333e -->|defined in| 7a09e708_c090_71c0_8138_7343699b1865
  style fc662a49_04f8_23d0_0af0_44d9054f333e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/content/utils.ts lines 447–474

export function safeParseFrontmatter(source: string, id?: string) {
	try {
		return parseFrontmatter(source, { frontmatter: 'empty-with-spaces' });
	} catch (err: any) {
		const markdownError = new MarkdownError({
			name: 'MarkdownError',
			message: err.message,
			stack: err.stack,
			location: id
				? {
						file: id,
					}
				: undefined,
		});

		if (isYAMLException(err)) {
			markdownError.setLocation({
				file: id,
				line: err.mark.line,
				column: err.mark.column,
			});

			markdownError.setMessage(err.reason);
		}

		throw markdownError;
	}
}

Subdomains

Frequently Asked Questions

What does safeParseFrontmatter() do?
safeParseFrontmatter() is a function in the astro codebase, defined in packages/astro/src/content/utils.ts.
Where is safeParseFrontmatter() defined?
safeParseFrontmatter() is defined in packages/astro/src/content/utils.ts at line 447.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free