-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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): feature/docs slug frontmatter (v2) #2771
Conversation
@@ -79,7 +79,7 @@ describe('simple site', () => { | |||
|
|||
expect(data).toEqual({ | |||
id: 'foo/baz', | |||
permalink: '/docs/foo/baz', | |||
permalink: '/docs/any/pathname.html', // pathname is not "affected" by markdown folder |
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.
if a markdown file is in a subfolder, not sure we want to force the user to have a pathname prefixed by that folder's name. He may group files logically by folder, but still want custom pathnames? don't know
Deploy preview for docusaurus-2 ready! Built with commit 5fd47be |
Hi @JoelMarcey @yangshun I think it's more "clean" than the workaround of having What I wonder is, how much freedom should we give to the user regarding this customization. If a doc is in The url would be by default: Using
What I think we should do for now is probably keep it simple for the Watchman usecase:
If there's more need, we can still build a generic hook to be able to rewrite pathnames before generating the final routes. In such case the user would have full control, somehow like: const customizeRoutePathname = (route) => {
if ( route.pathname === "/docs/2.0.0-alpha.50/subfolders/someDoc" ) {
return pathname + ".html
}
return pathname;
} As I don't really know how common is this need, wonder if it's worth investing too much |
I agree. We have not seen a huge ask for this fix for v1 sites. I say we start simple with the Watchman fix - which probably fixes some other affected sites too - and see if we have to do any further work. |
Hi, I've decided to rename the frontmatter "slug", and only affect the last section of the pathname (as an user would expect from a slug). I think it's the most simple, intuitive, minimal api surface to solve the watchman problem. Ready to review. |
@lex111 what do you think about this PR? Since you're more familiar with the docs plugin now. |
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.
Should we mention about this feature on "Migration from v1 to v2" doc?
For example, in v1 the cleanUrl
option may be disabled, so we could update the following sentence on that doc page, like so:
- cleanUrl - Clean URL is used by default now.
+ cleanUrl - Clean URL is used by default now. However you can specify slug to add HTML extension to your URLs.
Hi @lex111 Thanks for telling me about clean urls. As far as I understand, in v1, we could access doc at /doc and /doc.html, and there was no canonical url. For the migration guide, I'd recommend the user to choose between If this is really needed, we could write the same page twice to the FS and add the same canonical url to both pages, that would reproduce the behavior of v1, but it's not something I've worked on yet and I think the client-side redirect should be enough. I'd rather document the migration in the client side redirect plugin PR, what do you think? |
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.
Just doc improvement and I think we ready to merge.
Co-authored-by: Alexey Pyltsyn <[email protected]>
change applied to the doc, thanks |
Was wondering if we should also support this feature for the blog posts (front matter) and pages (comp static value) too? If v1 users have For example, if D1 site had That's likely a niche usecase. I think we should merge this PR anyway, and improve if some user complains during a migration. Note: Watchman is not coming from D1 and not affected. Edit: the non-migrated D1 sites of the spreadsheet that seems to use |
I think we should not do this, especially when there is a official redirect plugin, the end user can easily add needed redirects, right? |
Agree We could merge this PR, and see later if one of the 4 sites with |
@slorber thank you! |
Motivation
Solve #2697
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Jest tests