FrontmatterHolder Class — astro Architecture
Architecture documentation for the FrontmatterHolder class in frontmatterHolders.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD e6a43f7b_9c92_14b9_3549_5c4223076591["FrontmatterHolder"] f60cb650_8357_a1b3_0ec1_4fa2349de8ca["frontmatterHolders.ts"] e6a43f7b_9c92_14b9_3549_5c4223076591 -->|defined in| f60cb650_8357_a1b3_0ec1_4fa2349de8ca 4008227b_29c1_47f7_5982_789b0b38b1ba["constructor()"] e6a43f7b_9c92_14b9_3549_5c4223076591 -->|method| 4008227b_29c1_47f7_5982_789b0b38b1ba
Relationship Graph
Source Code
packages/language-tools/language-server/src/core/frontmatterHolders.ts lines 93–166
export class FrontmatterHolder implements VirtualCode {
id = 'frontmatter-holder';
mappings: CodeMapping[];
embeddedCodes: VirtualCode[];
public hasFrontmatter = false;
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 the file is not part of a collection, we don't need to do anything
if (!this.collection) {
return;
}
const frontmatterContent =
frontmatterRE
.exec(this.snapshot.getText(0, this.snapshot.getLength()))?.[0]
.replaceAll('---', ' ') ?? '';
this.hasFrontmatter = frontmatterContent.length > 0;
this.embeddedCodes.push({
id: `yaml_frontmatter_${this.collection}`,
languageId: 'yaml',
snapshot: {
getText: (start, end) => frontmatterContent.substring(start, end),
getLength: () => frontmatterContent.length,
getChangeRange: () => undefined,
},
mappings: [
{
sourceOffsets: [0],
generatedOffsets: [0],
lengths: [frontmatterContent.length],
data: {
verification: true,
completion: true,
semantic: true,
navigation: true,
structure: true,
format: false,
},
},
],
});
if (this.hasFrontmatter) {
const yaml2tsResult = yaml2ts(frontmatterContent, this.collection);
this.embeddedCodes.push(yaml2tsResult.virtualCode);
}
}
}
Source
Frequently Asked Questions
What is the FrontmatterHolder class?
FrontmatterHolder is a class in the astro codebase, defined in packages/language-tools/language-server/src/core/frontmatterHolders.ts.
Where is FrontmatterHolder defined?
FrontmatterHolder is defined in packages/language-tools/language-server/src/core/frontmatterHolders.ts at line 93.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free