-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e464ae8
commit 5b9a1f3
Showing
10 changed files
with
61 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type fsMod from 'node:fs'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { AstroConfig, ContentEntryType } from '../@types/astro.js'; | ||
import { getContentPaths, parseFrontmatter } from './utils.js'; | ||
import { MARKDOWN_CONTENT_ENTRY_TYPE_NAME } from './consts.js'; | ||
|
||
export async function getMarkdownContentEntryType( | ||
config: Pick<AstroConfig, 'root' | 'srcDir'>, | ||
fs: typeof fsMod | ||
): Promise<ContentEntryType> { | ||
const contentPaths = getContentPaths(config, fs); | ||
return { | ||
name: MARKDOWN_CONTENT_ENTRY_TYPE_NAME, | ||
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, | ||
}; | ||
}, | ||
contentModuleTypes: await fs.promises.readFile( | ||
new URL('./markdown-types.d.ts', contentPaths.templateDir), | ||
'utf-8' | ||
), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare module 'astro:content' { | ||
interface Render { | ||
'.md': Promise<{ | ||
Content: import('astro').MarkdownInstance<{}>['Content']; | ||
headings: import('astro').MarkdownHeading[]; | ||
remarkPluginFrontmatter: Record<string, any>; | ||
}>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
packages/astro/src/vite-plugin-markdown/content-entry-type.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters