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(content-docs): add trailing slash to contentDirs, before passing it to isMDXPartial #8275

Merged

Conversation

denis-alkhelali
Copy link
Contributor

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

If you have multi-instances and versioning and you're trying to import partial MDX to a file from cut version, you'll get console error. This happens because a paths to the directory with the next version docs and directory with docs for some version starts with the same, i.e "**/instance" and "**/instance_versioned_docs/**". So, isMDXPartial() uses wrong directory as a root directory as a root. We need to append slashes to contentDirs, so that "**/instance/**"(slash added) will not mix up with "**/instance_versioned_docs/**"

Example:

In my docs folder I have a folder "_includes" with MDX partials. I use multi-instances, "instance" is a name of one of the instances. I import partials like that:
import Partial from '@site/instance/_includes/_partial.mdx';
Then I cut a new version and want to update the imports to "versioned_docs" path, so I use:
import Partial from '@site/instance_versioned_docs/version-1.0.0/_includes/_partial.mdx';

That's the error I get:
[ERROR] MDX loader can't read MDX metadata file "path-to-my-repo\.docusaurus\docusaurus-plugin-content-docs\instance\site-instance-versioned-docs-version-1-0-0-includes-partial-mdx-d57.json". Maybe the isMDXPartial option function was not provided?
[ERROR] Error: ENOENT: no such file or directory, open 'path-to-my-repo\.docusaurus\docusaurus-plugin-content-docs\instance\site-instance-versioned-docs-version-1-0-0-includes-partial-mdx-d57.json'
[INFO] Docusaurus version: 2.2.0
Node version: v16.14.0
error Command failed with exit code 1.

The same thing when I use relative paths.

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 2, 2022
@netlify
Copy link

netlify bot commented Nov 2, 2022

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit db81c16
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6361cbd7d08e690009509fe6
😎 Deploy Preview https://deploy-preview-8275--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 settings.

@github-actions
Copy link

github-actions bot commented Nov 2, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 60 🟢 97 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 85 🟢 100 🟢 100 🟢 100 🟢 90 Report

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Nov 2, 2022
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks for finding this edge case 👍

wonder if there's an easy way to add a test ensuring it keeps working

@slorber slorber added the to backport This PR is planned to be backported to a stable version of Docusaurus label Nov 2, 2022
@denis-alkhelali
Copy link
Contributor Author

@slorber Hi, could you please help with merging this? Windows Tests failed due to timeout, maybe we can just re-run them? Thanks

@slorber
Copy link
Collaborator

slorber commented Nov 23, 2022

Sorry, I just forgot to merge ;)

@slorber slorber merged commit a4d935a into facebook:main Nov 23, 2022
slorber pushed a commit that referenced this pull request Jan 26, 2023
@slorber slorber added backported This PR has been backported to a stable version of Docusaurus and removed to backport This PR is planned to be backported to a stable version of Docusaurus labels Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR has been backported to a stable version of Docusaurus 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

3 participants