diff options
author | 2024-09-26 14:59:39 +0100 | |
---|---|---|
committer | 2024-09-26 14:59:39 +0100 | |
commit | a19530e377b7d7afad58a33b23c0a5df1c376819 (patch) | |
tree | 40eb6c305f2daec6bf2d5ef41eaba05f1e8dd8d9 /packages/integrations/mdx/src/utils.ts | |
parent | acf264d8c003718cda5a0b9ce5fb7ac1cd6641b6 (diff) | |
download | astro-a19530e377b7d7afad58a33b23c0a5df1c376819.tar.gz astro-a19530e377b7d7afad58a33b23c0a5df1c376819.tar.zst astro-a19530e377b7d7afad58a33b23c0a5df1c376819.zip |
Parse frontmatter ourselves (#12075)
Diffstat (limited to 'packages/integrations/mdx/src/utils.ts')
-rw-r--r-- | packages/integrations/mdx/src/utils.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/packages/integrations/mdx/src/utils.ts b/packages/integrations/mdx/src/utils.ts index ad98abb9e..7dcd4a14c 100644 --- a/packages/integrations/mdx/src/utils.ts +++ b/packages/integrations/mdx/src/utils.ts @@ -1,7 +1,7 @@ +import { parseFrontmatter } from '@astrojs/markdown-remark'; import type { Options as AcornOpts } from 'acorn'; import { parse } from 'acorn'; import type { AstroConfig, AstroIntegrationLogger, SSRError } from 'astro'; -import matter from 'gray-matter'; import { bold } from 'kleur/colors'; import type { MdxjsEsm } from 'mdast-util-mdx'; import type { PluggableList } from 'unified'; @@ -48,9 +48,9 @@ export function getFileInfo(id: string, config: AstroConfig): FileInfo { * Match YAML exception handling from Astro core errors * @see 'astro/src/core/errors.ts' */ -export function parseFrontmatter(code: string, id: string) { +export function safeParseFrontmatter(code: string, id: string) { try { - return matter(code); + return parseFrontmatter(code, { frontmatter: 'empty-with-spaces' }); } catch (e: any) { if (e.name === 'YAMLException') { const err: SSRError = e; |