Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 9 additions & 5 deletions packages/docs/site/bin/refresh-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ const existingContent = fs.readFileSync(destinationPath, 'utf-8');
const frontmatterRegex = /^---\n([\s\S]*?)\n---/;
const existingFrontmatter = existingContent.match(frontmatterRegex)?.[0] || '';

// The destination file's frontmatter sets `format: md` so Docusaurus parses
// it as plain CommonMark instead of MDX. Without that, unescaped `{...}` or
// `<...>` in PR titles (e.g. `@php-wasm/{web,node}-5-2`) would be treated as
// JSX and crash the build.
const changelogWithFrontmatter = existingFrontmatter + '\n\n' + changelog;
// Docusaurus 3 parses `.md` files through the MDX pipeline, so unescaped
// `{` / `}` in PR titles (e.g. `@php-wasm/{web,node}-5-2`) get read as JSX
// expressions and crash the SSG with `ReferenceError: web is not defined`.
// The destination file's frontmatter sets `format: md` as a hint, but that
// alone has not been enough in practice — escape the braces directly so the
// content is inert regardless of how Docusaurus parses it.
const escapedChangelog = changelog.replace(/[{}]/g, (c) => '\\' + c);
const changelogWithFrontmatter =
existingFrontmatter + '\n\n' + escapedChangelog;

// Write the modified changelog to the destination file
fs.writeFileSync(destinationPath, changelogWithFrontmatter, 'utf-8');
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/site/docs/main/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ format.
### Various

- [Docs] Update trusted publisher setup instructions. ([#3505](https://github.com/WordPress/wordpress-playground/pull/3505))
- [PHP] Align @php-wasm/{web,node}-5-2 with workspace and add READMEs. ([#3506](https://github.com/WordPress/wordpress-playground/pull/3506))
- [PHP] Align @php-wasm/\{web,node\}-5-2 with workspace and add READMEs. ([#3506](https://github.com/WordPress/wordpress-playground/pull/3506))

### Contributors

Expand Down
Loading