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): get correct error line numbers, handle front matter + contentTitle with remark #9386

Merged
merged 3 commits into from
Oct 9, 2023

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Oct 9, 2023

Motivation

As users upgrade to v3 they are going to encounter compilation errors presenting line numbers. This ensures that the displayed line numbers are correct to avoid confusing users.

The way we used to handle MDX files is problematic because we stripped front matter and contentTitle before passing the string to MDX, and all errors usually had incorrect line numbers.

This was also requested that it should be possible to access front matter while writing a remark plugin: now this is possible.

Fix #3935

Note: although the logic to generate the contentTitle string probably has changed a bit, I consider this is not a breaking change: turning the h1 line AST to a proper string is a best-effort and considered as an implementation detail. If you care about SEO title etc, you must provide an explicit front matter title, in particular if you use fancy JSX/HTML syntax in the h1 title.

Test Plan

CI, Argos

Test links

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

@slorber slorber added pr: bug fix This PR fixes a bug in a past release. Argos Add this label to run UI visual regression tests. See argos.yml GH action. labels Oct 9, 2023
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 9, 2023
@netlify
Copy link

netlify bot commented Oct 9, 2023

[V2]

Name Link
🔨 Latest commit c1f592b
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6523dd906f14fb0008b8ab4d
😎 Deploy Preview https://deploy-preview-9386--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

github-actions bot commented Oct 9, 2023

⚡️ Lighthouse report for the deploy preview of this PR

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

@argos-ci
Copy link

argos-ci bot commented Oct 9, 2023

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

Build Status Details Updated (UTC)
default (Inspect) 🧿 Changes detected (Review) 2 changes Oct 9, 2023, 11:17 AM

@github-actions
Copy link

github-actions bot commented Oct 9, 2023

Size Change: 0 B

Total Size: 1.13 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 861 kB
website/build/index.html 41.4 kB

compressed-size-action

@slorber slorber merged commit d86aa0d into main Oct 9, 2023
29 of 31 checks passed
@slorber slorber deleted the slorber/handle-frontmatter-contentTitle-in-remark branch October 9, 2023 12:55
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.

@docusuarus/mdx-loader frontmatter removal prevents rehype vfile having correct line numbers
2 participants