Skip to content

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

Open
jibin7jose wants to merge 1 commit into
facebook:mainfrom
jibin7jose:fix-mdx-title
Open

fix(utils): allow MDX to detect title when a component is exported before h1#12335
jibin7jose wants to merge 1 commit into
facebook:mainfrom
jibin7jose:fix-mdx-title

Conversation

@jibin7jose

@jibin7jose jibin7jose commented Aug 2, 2026

Copy link
Copy Markdown

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]

Built without sensitive environment variables

Name Link
🔨 Latest commit baf4059
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a6eed327f5a280008481f97
😎 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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

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>

1 participant