Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mdx-loader): improve mdxJsxTextElementToHtml #9262

Merged
merged 3 commits into from Aug 25, 2023

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Aug 25, 2023

Motivation

MDX headings are converted to html string to generate toc items.

This is a quite hacky and unreliable process that we already used in MDX v1. Now that MDX v2 is more strict, we have to implement more of this hacky process ourselves.

This PR slightly improves the process by allowing users to pass a className attribute to heading JSX elements.

This is used on a few websites, notably the React-Native website:

### <div class="label required basic">Required</div> **`data`**

https://reactnative.dev/docs/flatlist#required-data

Letting the className pass-through the TOC heading serialization is important to let users customize how it renders on the TOC.

CleanShot 2023-08-25 at 18 37 35@2x

It is possible that supporting other attributes become useful in the future. If it's the case I'd prefer you to let me know so that we can study that on a case-by-case basis.

Ultimately, this remains a workaround. We should probably emit real JSX nodes instead of HTML strings to render the TOC, but that's a more complex refactor.

Test Plan

CI

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 25, 2023
@slorber slorber added pr: bug fix This PR fixes a bug in a past release. and removed CLA Signed Signed Facebook CLA labels Aug 25, 2023
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 25, 2023
@netlify
Copy link

netlify bot commented Aug 25, 2023

[V2]

Name Link
🔨 Latest commit 1d26a47
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/64e8db788957f200089d2ccd
😎 Deploy Preview https://deploy-preview-9262--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 site configuration.

@github-actions
Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 78 🟢 97 🟢 92 🟢 100 🟠 89 Report
/docs/installation 🟠 74 🟢 98 🟢 92 🟢 100 🟠 89 Report

@slorber slorber added the Argos Add this label to run UI visual regression tests. See argos.yml GH action. label Aug 25, 2023
@slorber slorber merged commit 9868bab into main Aug 25, 2023
30 of 31 checks passed
@slorber slorber deleted the slorber/improve-mdxJsxTextElementToHtml branch August 25, 2023 17:05
@argos-ci
Copy link

argos-ci bot commented Aug 25, 2023

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 🧿 Changes detected (Review) 1 change Aug 25, 2023, 5:10 PM

@github-actions
Copy link

Size Change: 0 B

Total Size: 1.11 MB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 117 kB
website/build/assets/css/styles.********.css 113 kB
website/build/assets/js/main.********.js 837 kB
website/build/index.html 41.3 kB

compressed-size-action

This was referenced Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Argos Add this label to run UI visual regression tests. See argos.yml GH action. 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.

None yet

2 participants