fix(mdx): handle double curly braces serialization in MDX payload attributes
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 48s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 48s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
This commit is contained in:
@@ -62,7 +62,13 @@ export async function getPostBySlug(slug: string, locale: string): Promise<PostD
|
||||
const fileContent = await fs.readFile(filePath, 'utf-8');
|
||||
const { data, content } = matter(fileContent);
|
||||
|
||||
let parsedContent = content;
|
||||
// Fix MDX data props dropped by next-mdx-remote
|
||||
// Payload serializes as data={{"items":...}} which Acorn treats as a Block statement.
|
||||
const fixedContent = content.replace(/data=\{\{([\s\S]*?)\}\}/g, (match, p1) => {
|
||||
return 'data="{' + p1.replace(/"/g, '"') + '}"';
|
||||
});
|
||||
|
||||
let parsedContent = fixedContent;
|
||||
try {
|
||||
if (content.trim().startsWith('{')) {
|
||||
parsedContent = JSON.parse(content);
|
||||
|
||||
Reference in New Issue
Block a user