From 677ed584563dfa2a8f376f7bd0aedd4adf674860 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Thu, 9 Feb 2023 12:16:18 -0500 Subject: [PATCH] oops, forgot to commit untracked --- .../vite-plugin-markdown/content-entry-type.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 packages/astro/src/vite-plugin-markdown/content-entry-type.ts 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, + }; + }, +};