Skip to content

fix(utils): allow MDX to detect title when a component is exported before h1 - #12335

Merged
slorber merged 3 commits into
meta:mainfrom
jibin7jose:fix-mdx-title
Aug 21, 2026
Merged

slorber merged 3 commits into
meta:mainfrom
jibin7jose:fix-mdx-title

Conversation

@jibin7jose

@jibin7jose jibin7jose commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

New
This PR fixes a bug where Docusaurus fails to detect the title of an MDX page if a React component is exported before the first <h1> heading. The regex in parseMarkdownContentTitle was updated to properly strip out export statements (in addition to import statements) before looking for the title.

Closes #12331

Test Plan

  • Added a unit test to markdownUtils.test.ts to verify parsing works correctly when an export block precedes the <h1> title.

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Aug 2, 2026
@netlify

netlify Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

✅ [V2]

Name Link
🔨 Latest commit d932565
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a88792caba6ed00087ad296
😎 Deploy Preview https://deploy-preview-12335--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Aug 21, 2026

@slorber slorber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

Just completed a bit the tests to represent real-world scenarios

@slorber
slorber merged commit abeec34 into meta:main Aug 21, 2026
36 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MDX doesn't detect title if a React component is defined before <h1>

2 participants