Home / Class/ FrontmatterHolder Class — astro Architecture

FrontmatterHolder Class — astro Architecture

Architecture documentation for the FrontmatterHolder class in frontmatter.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  448e349c_6c7a_24b8_080c_eb7a40d94536["FrontmatterHolder"]
  ea4d1e16_3d0b_5a14_84c7_af64d3dde1b2["frontmatter.ts"]
  448e349c_6c7a_24b8_080c_eb7a40d94536 -->|defined in| ea4d1e16_3d0b_5a14_84c7_af64d3dde1b2
  4a7bd5b9_a468_adcb_6659_d09e3dcf1701["constructor()"]
  448e349c_6c7a_24b8_080c_eb7a40d94536 -->|method| 4a7bd5b9_a468_adcb_6659_d09e3dcf1701

Relationship Graph

Source Code

packages/language-tools/ts-plugin/src/frontmatter.ts lines 86–127

export class FrontmatterHolder implements VirtualCode {
	id = 'frontmatter-holder';
	mappings: CodeMapping[];
	embeddedCodes: VirtualCode[];

	constructor(
		public fileName: string,
		public languageId: string,
		public snapshot: ts.IScriptSnapshot,
		public collection: string | undefined,
	) {
		this.mappings = [
			{
				sourceOffsets: [0],
				generatedOffsets: [0],
				lengths: [this.snapshot.getLength()],
				data: {
					verification: true,
					completion: true,
					semantic: true,
					navigation: true,
					structure: true,
					format: true,
				},
			},
		];

		this.embeddedCodes = [];
		this.snapshot = snapshot;

		if (!this.collection) return;

		const frontmatterContent = frontmatterRE.exec(
			this.snapshot.getText(0, this.snapshot.getLength()),
		)?.[0];

		if (!frontmatterContent) return;

		const yaml2tsResult = yaml2ts(frontmatterContent, this.collection);
		this.embeddedCodes.push(yaml2tsResult.virtualCode);
	}
}

Frequently Asked Questions

What is the FrontmatterHolder class?
FrontmatterHolder is a class in the astro codebase, defined in packages/language-tools/ts-plugin/src/frontmatter.ts.
Where is FrontmatterHolder defined?
FrontmatterHolder is defined in packages/language-tools/ts-plugin/src/frontmatter.ts at line 86.

Analyze Your Own Codebase

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

Try Supermodel Free