-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(v2): add support to ignore files in pages plugin #3196
Conversation
Deploy preview for docusaurus-2 ready! Built with commit c36e84d |
this.addDependency(metadataPath); | ||
const metadata = await readFile(metadataPath, 'utf8'); | ||
exportStr += `\nexport const metadata = ${metadata};`; | ||
if (existsSync(metadataPath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer async variant whenever it's not too annoying to apply like here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not totally sure of what this code do but I think we should not modify the loader there, as it's less fail-fast, and could silently ignore some important errors (like not having the createData and mdx loader paths in sync, not sure)
Instead we could modify the loader usage in pages like:
metadataPath: (mdxPath: string) => {
if (isIgnored(mdxPath)) {
return undefined;
}
const aliasedSource = aliasedSitePath(mdxPath, siteDir);
return path.join(
dataDir,
`${docuHash(aliasedSource)}.json`,
);
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did same earlier but then I tried importing file in docs and blogs plugins and failed in both.
That looks good but a few things to change.
Wonder what's the behavior if I put frontmatter in a _file.md, maybe we should throw an exception explaining this is forbidden to the user. Also worth to add a test for that
Frontmatter is not in plugin control. It will require changes to mdx-loader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will take a look on next review.
I think we could have a mdx loader option like forbidFrontmatter: (mdxPath: string) => boolean
packages/docusaurus-plugin-content-pages/src/pluginOptionSchema.ts
Outdated
Show resolved
Hide resolved
That looks good but a few things to change. Wonder what's the behavior if I put frontmatter in a _file.md, maybe we should throw an exception explaining this is forbidden to the user. Also worth to add a test for that |
Co-authored-by: Sébastien Lorber <[email protected]>
This reverts commit 4457a2e.
That's nice. @anshulrgoyal I think we should provide this feature as a global markdown feature. What about trying to generalize this pattern?, maybe providing in core or utils a globby wrapper that by default ignore the _ prefixed files? We'd use it in all plugins then. Do you feel it could be useful to split docs/blogs into smaller parts as well? or maybe it's overkill for now? |
Hey, sorry about the necro: I've been trying to debug why my file Is there an existing workaround? |
I've found a (rather nasty) workaround: put partials inside It would be nice if this |
Yes I'd like to make _ work consistently everywhere by default The workaround for now can be to put content in You can import it with Edit: hmmm actually this probably doesn't work as there's no mdx loader for src/components being registered, so your workaround is probably the only one currently Created another dedicated issue: #4984 |
Motivation
Add support to ignore files in the pages directory. It will help splitting markdown pages.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
By adding test
Working example->https://deploy-preview-3196--docusaurus-2.netlify.app/build/examples/markdownPageExample