diff --git a/packages/astro/src/vite-plugin-markdown/content-entry-type.ts b/packages/astro/src/vite-plugin-markdown/content-entry-type.ts new file mode 100644 index 000000000..b6b27fedd --- /dev/null +++ b/packages/astro/src/vite-plugin-markdown/content-entry-type.ts @@ -0,0 +1,16 @@ +import type { ContentEntryType } from 'astro'; +import { fileURLToPath } from 'node:url'; +import { parseFrontmatter } from '../content/utils.js'; + +export const markdownContentEntryType: ContentEntryType = { + extensions: ['.md'], + async getEntryInfo({ fileUrl, contents }: { fileUrl: URL; contents: string }) { + const parsed = parseFrontmatter(contents, fileURLToPath(fileUrl)); + return { + data: parsed.data, + body: parsed.content, + slug: parsed.data.slug, + rawData: parsed.matter, + }; + }, +};