Open MarkShawn2020 opened 2 years ago
I think we should refuse any post slug that may overwrite a "built-in page", like the list pages, archive page, tags page, etc. Not sure how easy that is.
Do you get duplicate routes warnings?
I think we should refuse any post slug that may overwrite a "built-in page", like the list pages, archive page, tags page, etc. Not sure how easy that is.
Do you get duplicate routes warnings?
From my test, no duplicated routes would be warned, unless you explictly write two or more files with the same slug.
I think we should refuse any post slug that may overwrite a "built-in page", like the list pages, archive page, tags page, etc. Not sure how easy that is.
Do you get duplicate routes warnings?
see packages/docusaurus-plugin-content-blog/src/frontMatter.ts:66
, there is a joi config for field of slug.
If we want to fix this, we would have to fix shadowing of the /archive
page, /tags
page, /page/2
page, etc. as well. That would require the front matter validator to know about what built-in pages would be generated.
Otherwise, we could do it at the createPage
phase, instead of validation. That should work the same.
If we want to fix this, we would have to fix shadowing of the
/archive
page,/tags
page,/page/2
page, etc. as well. That would require the front matter validator to know about what built-in pages would be generated.Otherwise, we could do it at the
createPage
phase, instead of validation. That should work the same.
From my opinion, to implement the logic within createPage
may be more reasonable, let the joi itself focus more on the grammar domain, rather than the business one.
Do we really always want the 1st page to be the home?
Shouldn't we allow customizing this pagination path logic?
function permalink(page: number) {
return page > 0
? normalizeUrl([basePageUrl, `page/${page + 1}`])
: basePageUrl;
}
Doesn't it make sense to replace the default homepage of your blog with the archive page that you swizzle to display it nicely? I could want this.
I'm not fan of a specific solution using frontmatter validation
hink we should refuse any post slug that may overwrite a "built-in page", like the list pages, archive page, tags page, etc. Not sure how easy that is. Do you get duplicate routes warnings?
From my test, no duplicated routes would be warned, unless you explicitly write two or more files with the same slug.
I just wrote slug: /
in a blog post and got a warning 🤷♂️ you can make it throw with config.
Isn't it good enough? Can we make it more visible, and the wording easier to understand?
Yes—we do get a warning, but the message is kind of vague. Within the realm of a plugin we can give a much more sensible diagnostic. I think that's the point of this issue.
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
A md file with frontmatter with slug of
/
woule generate path as/blog/
by default.But actually,
/blog/
would redirect to be/blog
, i.e. the home page of blogs.Steps to reproduce
place a md file under blog dir, i.e.
/blog/test.md
:Expected behavior
/blog/
(or/blog/xxx
), which is rendered from/blog/test.md
/
in the building part, e.g. added the ruler injoi
inpackages/docusaurus-plugin-content-blog/src/frontMatter.ts:66
.Actual behavior
/blog
or/blog/
all points to the home page of blog/blog/test.md
/
failed to be parsed at the same time (e.g.<div style="color: red">xxx</div>
is invalid since the valid jsx grammar isstyle={{color: "red"}}
.), then the build engine would not report the error directly from this arcticle, but from the page(containing of 5 arcticles defualt), which is very confusing to the developers (e.g. me)./blog/
should be just skipped ...Your environment
Self-service