-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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): support external links & linking to docs from other sidebars #1052
feat(v2): support external links & linking to docs from other sidebars #1052
Conversation
Deploy preview for docusaurus-preview ready! Built with commit 4f0b188 |
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.
Looks great. Kinda happy also by the fact that you are able to implement it in v2 easily @SleepWalker
We need to document this in the future since there is a lot of things now, including 'ref' means including it in sidebar but not including it at next/prev.
The change to ids
to items
seems to make sense since we allow href linking other than id
@yangshun I have more questions:
|
@SleepWalker I'll get back to you on this soon. We're currently getting ready for a demo and will be holding off on merging v2 PRs these few days. |
Let's leave v1 implementation in another PR. Small changes is easier to review. @SleepWalker can you resolve the conflicts ? |
0966b72
to
9ed899c
Compare
@endiliey yep, they are resolved |
Shall let @yangshun press the merge button |
This PR implements #827, #868 (v1 PR pending)
Motivation
This PR will improve sidebar to support:
ids
toitems
)Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
I have added some examples in
sidebar.json
. It looks like this:The
type
field can be one of the following:doc
— low level name for simple link to doc. Should containid
fieldref
— link to some docId, but without binding this doc to current sidebar. Should containid
fieldlink
— the type used to render any link in sidebar (doc and ref are converted to this type too). Should containhref
andlabel
fieldscategory
— category :) should containlabel
anditems
fields (I think this should be a better name, because we will handle not only ids in this array)I'm normalizing sidebars to this low-level format immediately after reading them (including versioned sidebars) in
v2/lib/load/docs/sidebars.js
. During normalization I'm checking, that all the items contain only allowed fields and that we won't have sub-sub-categories.Normalized structure is much more predictable and reliable, which allow us to simplify logic (it won't be needed to test for each type of possible sidebar syntaxes in each function) during docs ordering and during sidebar rendering on client side. In future we can even more simplify this by implementing visitor pattern, like in e.g. babel.
Docs Paginator behavior
I've decided to ignore
ref
andlink
items, when building data for docs paginator. If you send user toref
doc, the sidebar will be changed. If you send user tolink
it may even leave our site. I think that's not expected behavior for the user.Unit tests
I've added one new test to test for
ref
andlink
processing in order.js. All other cases seems to be covered with older tests after I've fixed them