Finish go to selected paged from category sidebar#4323
Conversation
|
[V1] Deploy preview failure Built without sensitive environment variables with commit e2998f7 https://app.netlify.com/sites/docusaurus-1/deploys/60411f70eaefbc00073fd738 |
|
Deploy preview for docusaurus-2 failed. Built without sensitive environment variables with commit e2998f7 https://app.netlify.com/sites/docusaurus-2/deploys/60411f70737bf200070b220e |
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4323--docusaurus-2.netlify.app/classic/ |
|
Size Change: 0 B Total Size: 532 kB ℹ️ View Unchanged
|
slorber
left a comment
There was a problem hiding this comment.
Thanks for working on this
Left some inline review comments
let me know if you need any help to handle those
| if (Object.hasOwnProperty.call(item.link, 'type')) { | ||
| switch (item.link.type) { | ||
| case 'doc': | ||
| setInitialLink(item.link.id); |
There was a problem hiding this comment.
this is not correct, the id is not the URL path, as docs can use slugs they have ids that can be totally different from their final URL.
This requires resolving the id to the doc URL path
(+ shouldn't need setState)
There was a problem hiding this comment.
Is there a function for getting the URL path from a document id?
| item: unknown, | ||
| ): asserts item is SidebarItemCategoryJSON { | ||
| assertItem(item, ['items', 'label', 'collapsed', 'customProps']); | ||
| assertItem(item, ['items', 'label', 'collapsed', 'link', 'customProps']); |
There was a problem hiding this comment.
We need to validate that the link attribute is valid in this function + add unit tests
There was a problem hiding this comment.
I might need some help on this one
ben-qnimble
left a comment
There was a problem hiding this comment.
Thanks for working on this
Left some inline review comments
let me know if you need any help to handle those
Yeah, I think I'll need help on what's left. Mostly decoding the url from the doc id and validation on the link. Thanks
| if (Object.hasOwnProperty.call(item.link, 'type')) { | ||
| switch (item.link.type) { | ||
| case 'doc': | ||
| setInitialLink(item.link.id); |
There was a problem hiding this comment.
Is there a function for getting the URL path from a document id?
|
Hi, what's the status of this PR? I'd be really looking forward to this feature. @ben-qnimble In case you are still working on it, here are a few hints:
You need several hooks to extract this information, but here's a reference:
Just follow the pattern below to verify that I'm in need of this feature and it's a shame seeing it getting stalled multiple times now 🤦♂️ |
| <DocSidebarItem | ||
| tabIndex={collapsed ? '-1' : '0'} | ||
| key={childItem.label} | ||
| link={link} |
There was a problem hiding this comment.
Why bind this to the children elements? Only the category with link attribute should have a link associated right?
This is a complex feature and this PR is not really in the direction I'd like to take to provide a set of useful features to Docusaurus (in particular #2643) I'll try to see if there's anything to take here, but ultimately it's likely that I close it. I'll start to work on these features soon, this is the next big task on my todolist. |
|
Closing in favor of #5830 |
Motivation
Pull #3898 looks very helpful (sidebar category linking to doc) but it seems like it got stalled, so I'm trying to get it over the finish line by addressing issues mentioned in the pull request code review.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Please see #3898. I set a few categories to have links and verified that they work as expected.
Related PRs
Adding to the commits in #3898 to address code review comments.