Home / Function/ getFrontmatterStatus() — astro Function Reference

getFrontmatterStatus() — astro Function Reference

Architecture documentation for the getFrontmatterStatus() function in parseAstro.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  8b12482e_9dfd_7461_220d_06e0f855c59a["getFrontmatterStatus()"]
  0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9["parseAstro.ts"]
  8b12482e_9dfd_7461_220d_06e0f855c59a -->|defined in| 0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9
  b2606d14_70c4_bc93_1789_07a66f3d3311["getAstroMetadata()"]
  b2606d14_70c4_bc93_1789_07a66f3d3311 -->|calls| 8b12482e_9dfd_7461_220d_06e0f855c59a
  style 8b12482e_9dfd_7461_220d_06e0f855c59a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/language-tools/language-server/src/core/parseAstro.ts lines 77–124

function getFrontmatterStatus(ast: ParseResult['ast'], text: string): FrontmatterStatus {
	if (!ast.children || (ast.children && ast.children.length === 0)) {
		return {
			status: 'doesnt-exist',
			position: undefined,
		};
	}

	if (ast.children[0].type === 'frontmatter') {
		const frontmatter = ast.children[0];
		if (frontmatter.position) {
			if (frontmatter.position.end) {
				// HACK: The compiler as of 1.5.5 always return an ending position, even if there's only a frontmatter opening
				// This hack checks if the frontmatter's ending is the end of the file, and if so, checks if there's a `---`.
				// If there's not, it means the compiler returned the EOF with an opened frontmatter
				if (frontmatter.position.end.offset === text.length && !text.endsWith('---')) {
					return {
						status: 'open',
						position: {
							start: frontmatter.position.start,
							end: undefined,
						},
					};
				}

				return {
					status: 'closed',
					position: {
						start: frontmatter.position.start,
						end: frontmatter.position.end,
					},
				};
			}
			return {
				status: 'open',
				position: {
					start: frontmatter.position.start,
					end: undefined,
				},
			};
		}
	}

	return {
		status: 'doesnt-exist',
		position: undefined,
	};
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getFrontmatterStatus() do?
getFrontmatterStatus() is a function in the astro codebase, defined in packages/language-tools/language-server/src/core/parseAstro.ts.
Where is getFrontmatterStatus() defined?
getFrontmatterStatus() is defined in packages/language-tools/language-server/src/core/parseAstro.ts at line 77.
What calls getFrontmatterStatus()?
getFrontmatterStatus() is called by 1 function(s): getAstroMetadata.

Analyze Your Own Codebase

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

Try Supermodel Free