Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/docs/site/bin/refresh-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ const existingContent = fs.readFileSync(destinationPath, 'utf-8');
const frontmatterRegex = /^---\n([\s\S]*?)\n---/;
const existingFrontmatter = existingContent.match(frontmatterRegex)?.[0] || '';

const changelogWithFrontmatter = existingFrontmatter + '\n\n' + changelog;
// Docusaurus parses `.md` files as MDX, so unescaped `{...}` in PR titles
// (e.g. `@php-wasm/{web,node}-5-2`) gets evaluated as a JSX expression and
// crashes the build with "ReferenceError: web is not defined". Escape braces
// so they render as literal characters.
const mdxSafeChangelog = changelog.replace(/[{}]/g, '\\$&');

const changelogWithFrontmatter =
existingFrontmatter + '\n\n' + mdxSafeChangelog;

// Write the modified changelog to the destination file
fs.writeFileSync(destinationPath, changelogWithFrontmatter, 'utf-8');
Expand Down
Loading
Loading