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

Bug (v2): Meta description outputting MDX import statements #2601

Closed
jcomack opened this issue Apr 14, 2020 · 4 comments · Fixed by #2380
Closed

Bug (v2): Meta description outputting MDX import statements #2601

jcomack opened this issue Apr 14, 2020 · 4 comments · Fixed by #2380
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: intermediate Issues that are medium difficulty level, e.g. moderate refactoring with a clear test plan. help wanted Asking for outside help and/or contributions to this particular issue or PR.

Comments

@jcomack
Copy link
Contributor

jcomack commented Apr 14, 2020

🐛 Bug Report

MDX import statements which are required to be placed on the first line of a doc (i.e. after the doc header section), are being used in meta descriptions.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Create a new doc item.
  2. Write the necessary header section.
  3. Directly after the header section, add an import statement such as import MyComponent from '../src/components/MyComponent';.
  4. Add some text below the import statement.
  5. Visit the new doc item in your browser.
  6. View the page source and see that the meta descriptions all use the import statement and not the 'actual' text you wrote in your doc file.

Expected behavior

I expected to see the first line of my text in de meta descriptions.

Actual Behavior

The import statement is being used in the meta descriptions.

Your Environment

  • Docusaurus version used: v2.0.0-alpha.50
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Firefox 74.0.1, Node.js v10.19.0
  • Operating system and version (desktop or mobile): MacOSX High Sierra 10.13.6 (desktop)

Reproducible Demo

(Paste the link to an example repo, including a siteConfig.js, and exact instructions to reproduce the issue.)

https://github.com/Yoast/developer-site combined with https://github.com/yoast/developer-docs/

@jcomack jcomack 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 Apr 14, 2020
@lex111
Copy link
Contributor

lex111 commented Apr 14, 2020

I tried to fix it in this PR, but @yangshun did not approve of it. Unfortunately, in the current architecture, it is difficult to come up with something else.
@yangshun so can we give this PR another chance?

@yangshun
Copy link
Contributor

yangshun commented Apr 14, 2020

The fix might also fix #2607. A few suggestions I have:

  • Compile the Markdown/MDX into just text form before extracting the description. This will incur a performance cost but would eliminate the issue entirely
  • Add a description front matter field to override the automatic extraction of the description. This is troublesome for users but might be useful to have either way
  • Last resort - do the naive removal as proposed by @lex111 in fix(v2): ignore import declarations in excerpt #2380

Might be worth finding out how Gatsby and VuePress handles this.

@yangshun yangshun added difficulty: intermediate Issues that are medium difficulty level, e.g. moderate refactoring with a clear test plan. help wanted Asking for outside help and/or contributions to this particular issue or PR. and removed status: needs triage This issue has not been triaged by maintainers labels Apr 14, 2020
@lex111
Copy link
Contributor

lex111 commented Apr 14, 2020 via email

@yangshun
Copy link
Contributor

@lex111 let's go with your previous PR. It's better than having a buggy result now. Maybe we can also filter out require statements to make it more robust.

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 difficulty: intermediate Issues that are medium difficulty level, e.g. moderate refactoring with a clear test plan. help wanted Asking for outside help and/or contributions to this particular issue or PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants