Skip to content

Commit

Permalink
fix: clear gray-matter cache for rawData
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Dec 12, 2022
1 parent 3eb11c1 commit 345727e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/astro/src/content/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ function getFrontmatterErrorLine(rawFrontmatter: string, frontmatterKey: string)
*/
export function parseFrontmatter(fileContents: string, filePath: string) {
try {
// `matter` is empty string on cache results
// clear cache to prevent this
(matter as any).clearCache();
return matter(fileContents);
} catch (e: any) {
if (e.name === 'YAMLException') {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/vite-plugin-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export function astroContentServerPlugin({
const {
content: body,
data: unparsedData,
matter: rawData,
matter: rawData = '',
} = parseFrontmatter(rawContents, pathname);
const entryInfo = getEntryInfo({ entryPath: pathname, contentDir: paths.contentDir });
if (entryInfo instanceof Error) return;
Expand Down

0 comments on commit 345727e

Please sign in to comment.