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

Meta description incorrectly capturing JSX code in MDX docs #3700

Closed
MichaelStromberg opened this issue Nov 5, 2020 · 2 comments · Fixed by #3703
Closed

Meta description incorrectly capturing JSX code in MDX docs #3700

MichaelStromberg opened this issue Nov 5, 2020 · 2 comments · Fixed by #3703
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@MichaelStromberg
Copy link

🐛 Bug Report

When investigating the meta description for the docs pages, we observe code fragments rather than something else like a tag line. This often leads to unsatisfying excerpts when pasting content in a chat client like Slack or MatterMost:

MatterMostLinkToDocusaurus

There have been other issues that seem to touch on this topic, but the problem remains.

If you look at the page source, you can see how the code ends up in the meta description field:

DocusaurusPageSource

Not only does this affect our site, but it also affects the normal Docusaurus page. You'll find the same issue if you look at the page source for the Docusaurus Team Page. Here are the links for convenience:

The location of my Docusaurus repo is here: https://github.com/Illumina/NirvanaDocumentation

Negative example

If I try the following, everything works as it should:

  1. npx @docusaurus/init@next init my-website classic
  2. cd my-website
  3. npm run build
  4. npm run serve
  5. view http://localhost:3000/docs/mdx and check page source

In this case we see that the description is set to You can write JSX and use React components within your Markdown thanks to MDX.

We notice that in https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-init/templates/classic/docs/mdx.md, there are no JSX commands that get in the way.

In addition, we see that if description is added to the header of an MDX file, everything is fine:

Positive example

If we examine the following pages, we see that there are export statements that seem to incorrectly added into the metadata field:

Have you read the Contributing Guidelines on issues?

YES

To Reproduce

See examples above.

Expected behavior

The expectation is that JSX code will be skipped when extracting the meta description for a given page if one is not already provided in the header.

Actual Behavior

See screenshot above.

For https://illumina.github.io/NirvanaDocumentation/, the description is currently assigned the following:

export function TeamProfileCardCol(props) { return  }

Your Environment

Docusaurus version used: 2.0.0-alpha.66
Environment name and version: Node.js v10.19.0
Operating system and version: Ubuntu 20.04

Reproducible Demo

You can already view the page source for the following MDX pages:

My repo can be found here: https://github.com/Illumina/NirvanaDocumentation

@MichaelStromberg MichaelStromberg added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Nov 5, 2020
@slorber
Copy link
Collaborator

slorber commented Nov 6, 2020

thanks, should be fixed by #3703

@MichaelStromberg
Copy link
Author

That was impressively fast - thank you for the awesome work on Docusaurus!

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants