getFrontmatterLanguagePlugin() — astro Function Reference
Architecture documentation for the getFrontmatterLanguagePlugin() function in frontmatterHolders.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 544bcbe3_d83f_098b_80b4_40ceea84f0c9["getFrontmatterLanguagePlugin()"] f60cb650_8357_a1b3_0ec1_4fa2349de8ca["frontmatterHolders.ts"] 544bcbe3_d83f_098b_80b4_40ceea84f0c9 -->|defined in| f60cb650_8357_a1b3_0ec1_4fa2349de8ca 3bc53284_8ff2_c415_b4d2_8a6f79d11dde["getCollectionName()"] 544bcbe3_d83f_098b_80b4_40ceea84f0c9 -->|calls| 3bc53284_8ff2_c415_b4d2_8a6f79d11dde style 544bcbe3_d83f_098b_80b4_40ceea84f0c9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/core/frontmatterHolders.ts lines 41–91
export function getFrontmatterLanguagePlugin(
collectionConfig: CollectionConfig,
): LanguagePlugin<URI, FrontmatterHolder> {
return {
getLanguageId(scriptId) {
const fileType = SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS.find((ext) =>
scriptId.path.endsWith(`.${ext}`),
);
if (fileType) {
return SUPPORTED_FRONTMATTER_EXTENSIONS[
fileType as keyof typeof SUPPORTED_FRONTMATTER_EXTENSIONS
];
}
},
createVirtualCode(scriptId, languageId, snapshot) {
if (SUPPORTED_FRONTMATTER_EXTENSIONS_VALUES.includes(languageId)) {
return new FrontmatterHolder(
scriptId.fsPath.replace(/\\/g, '/'),
languageId,
snapshot,
getCollectionName(
collectionConfig,
// The scriptId here is encoded and somewhat normalized, as such we can't use it directly to compare with
// the file URLs in the collection config entries that Astro generates.
decodeURIComponent(scriptId.toString()).toLowerCase(),
),
);
}
},
typescript: {
extraFileExtensions: SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS.map((ext) => ({
extension: ext,
isMixedContent: true,
scriptKind: 7 satisfies ts.ScriptKind.Deferred,
})),
getServiceScript(astroCode) {
for (const code of forEachEmbeddedCode(astroCode)) {
if (code.id === VIRTUAL_CODE_ID) {
return {
code,
extension: '.ts',
scriptKind: 3 satisfies ts.ScriptKind.TS,
};
}
}
return undefined;
},
},
};
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does getFrontmatterLanguagePlugin() do?
getFrontmatterLanguagePlugin() is a function in the astro codebase, defined in packages/language-tools/language-server/src/core/frontmatterHolders.ts.
Where is getFrontmatterLanguagePlugin() defined?
getFrontmatterLanguagePlugin() is defined in packages/language-tools/language-server/src/core/frontmatterHolders.ts at line 41.
What does getFrontmatterLanguagePlugin() call?
getFrontmatterLanguagePlugin() calls 1 function(s): getCollectionName.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free