frontmatter.ts — astro Source File
Architecture documentation for frontmatter.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR ea4d1e16_3d0b_5a14_84c7_af64d3dde1b2["frontmatter.ts"] d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] ea4d1e16_3d0b_5a14_84c7_af64d3dde1b2 --> d9a92db9_c95e_9165_13ac_24b3d859d946 72d62155_7ca7_47f8_5bc1_b16efdc23a61["yaml2ts"] ea4d1e16_3d0b_5a14_84c7_af64d3dde1b2 --> 72d62155_7ca7_47f8_5bc1_b16efdc23a61 040ca79b_dadf_4383_efd2_c0b13744e9f1["language-core"] ea4d1e16_3d0b_5a14_84c7_af64d3dde1b2 --> 040ca79b_dadf_4383_efd2_c0b13744e9f1 41525615_7e06_b0e8_f601_674c57b118ee["typescript"] ea4d1e16_3d0b_5a14_84c7_af64d3dde1b2 --> 41525615_7e06_b0e8_f601_674c57b118ee style ea4d1e16_3d0b_5a14_84c7_af64d3dde1b2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { pathToFileURL } from 'node:url';
import { VIRTUAL_CODE_ID, yaml2ts } from '@astrojs/yaml2ts';
import {
type CodeMapping,
forEachEmbeddedCode,
type LanguagePlugin,
type VirtualCode,
} from '@volar/language-core';
import type ts from 'typescript';
const SUPPORTED_FRONTMATTER_EXTENSIONS = { md: 'markdown', mdx: 'mdx', mdoc: 'markdoc' };
const SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS = Object.keys(SUPPORTED_FRONTMATTER_EXTENSIONS);
const SUPPORTED_FRONTMATTER_EXTENSIONS_VALUES = Object.values(SUPPORTED_FRONTMATTER_EXTENSIONS);
export const frontmatterRE = /^---(.*?)^---/ms;
export type CollectionConfig = {
folder: string;
config: {
collections: {
hasSchema: boolean;
name: string;
}[];
entries: Record<string, string>;
};
};
function getCollectionName(collectionConfig: CollectionConfig[], fsPath: string) {
for (const collection of collectionConfig) {
if (collection.config.entries[fsPath]) {
return collection.config.entries[fsPath];
}
}
}
export function getFrontmatterLanguagePlugin(
collectionConfig: CollectionConfig[],
): LanguagePlugin<string, FrontmatterHolder> {
return {
getLanguageId(scriptId) {
const fileType = SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS.find((ext) =>
scriptId.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)) {
const fileName = scriptId.replace(/\\/g, '/');
return new FrontmatterHolder(
fileName,
languageId,
snapshot,
// In TypeScript plugins, unlike in the language server, the scriptId is just a string file path
// so we'll have to convert it to a URL to match the collection config entries
getCollectionName(collectionConfig, pathToFileURL(fileName).toString().toLowerCase()),
// ... (68 more lines)
Domain
Subdomains
Classes
Types
Dependencies
- language-core
- node:url
- typescript
- yaml2ts
Source
Frequently Asked Questions
What does frontmatter.ts do?
frontmatter.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in frontmatter.ts?
frontmatter.ts defines 2 function(s): getCollectionName, getFrontmatterLanguagePlugin.
What does frontmatter.ts depend on?
frontmatter.ts imports 4 module(s): language-core, node:url, typescript, yaml2ts.
Where is frontmatter.ts in the architecture?
frontmatter.ts is located at packages/language-tools/ts-plugin/src/frontmatter.ts (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/language-tools/ts-plugin/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free