Skip to content
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

Allow using one doc id in multiple sidebars #868

Closed
SleepWalker opened this issue Jul 23, 2018 · 18 comments
Closed

Allow using one doc id in multiple sidebars #868

SleepWalker opened this issue Jul 23, 2018 · 18 comments
Assignees
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@SleepWalker
Copy link
Contributor

🚀 Feature

Allow the same document to be specified in multiple sidebars.

Have you read the Contributing Guidelines on issues?

Yes

Motivation

Improve navigation across the docs

Currently we have a limitation. A document can be child of only one sidebar, which has a bad impact on navigation in case, when you have one sidebar containing "high level" TOC and multiple sidebars with some docs regarding "low level" details for corresponding high level doc.

For example you have the following sidebar.json:

{
  "docs": {
    "Guides": [
      "adding-blog",
      "custom-pages",
      "search",
      "navigation",
      "translation",
      "versioning"
    ]
  },
  "blog": {
    "General": [
      "adding-comments",
      "setup-author",
      "post-sharing",
      "blog-rss"
    ]
  }
}

To make the main sidebar shorter, we splitting more specific docs into a separate section with it's own sidebar. In this example document adding-blog links to more specific docs, like adding-comments. It would be great to have a link to adding-blog in "blog" sidebar to let the user return back to the "docs" sidebar and high-level article.

Pitch

The reason why we can not have one document in multiple sidebars (as far as I know) is because we need a way to decide which sidebar to show for document, that is in multiple sidebars.

To solve this problem I propose to use dot notation. E.g.:

{
  "docs": {
    "Guides": [
      "adding-blog",
      "..."
    ]
  },
  "blog": {
    "General": [
      "docs.adding-blog",
      "adding-comments",
      "..."
    ]
  }
}

This way we will know, that adding-blog should have "docs" sidebar, but at the same time "blog" sidebar will link to adding-blog too.

Alternatively we can use some prefix e.g. link:, to show, that this sidebar only links to that doc. This prefix can be extended to allow absolute links too, e.g. link:/storybook or link:https://external-docs.com.

And the most universal variant is to use objects instead of strings to allow for more precise and flexible configuration.

@SleepWalker
Copy link
Contributor Author

In case when this issue will be accepted, I can add support for custom links from #827

@endiliey
Copy link
Contributor

@SleepWalker

Are you planning to work on all of this or just the custom links support from #827 ?

@endiliey endiliey added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. major change difficulty: advanced Issues that are complex, e.g. large scoping for long-term maintainability. and removed major change difficulty: advanced Issues that are complex, e.g. large scoping for long-term maintainability. labels Jul 25, 2018
@SleepWalker
Copy link
Contributor Author

I would like to work on all of this. I think, that two issues can be solved in one pull request, because it is, actually the same part of the code.

But we need to decide with config structure first.

@endiliey
Copy link
Contributor

@SleepWalker

I think this is a great addition. I have one question though, why do we need a ... notation. Can't it be

{
  "docs": {
    "Guides": [
      "adding-blog"
    ]
  },
  "blog": {
    "General": [
      "docs.adding-blog",
      "adding-comments"
    ]
  }
}

@SleepWalker
Copy link
Contributor Author

that three dots was just three dots to indicate some "other" config entries. I've wrapped it in quotes so that it will be syntactically correct :)

@endiliey
Copy link
Contributor

endiliey commented Jul 25, 2018

My bad, kinda missed that. Maybe next time it should be written as // ...😁.

Anyway, I agree with the dot notation (e.g: docs.adding-blog). The idea of namespacing is great.

I think you can proceed as I think this won't break anything and will be an added feature.

@SleepWalker
Copy link
Contributor Author

ok.

What will we use for custom links from #827?

[
  "href:/foo/bar", // or `link`, or `url`?
]

or

[
  { // the same format as in siteConfig.js
    "href": "https://github.com",
    "label": "Github"
  }
]

The first one is shorter. The last one is the most flexible. We can also support doc field there.

I think, that there will be very few cases, when the user will need to link to some external resources from sidebar, so we can stick with the last example, because it is the most generic. In future it will possible to add shortcut syntax too.

@endiliey
Copy link
Contributor

Lets go with the last one. Shouldn't be too hard to change it if needed. 👍

@endiliey endiliey added the status: claimed Issue has been claimed by a contributor who plans to work on it. label Jul 27, 2018
@SleepWalker
Copy link
Contributor Author

@endiliey can I split the code from server/readMetadata.js into several js files to be able to cover them with tests or should I make a separate PR with refactoring only? Current code looks to me a little bit complicated to modify it without any tests written.

@endiliey
Copy link
Contributor

@SleepWalker sure, you can refactor it to many files or maybe smaller functions instead of many files as long as it doesnt change functionality. Tests are great.

If there isnt too much refactor, a separate PR might not be needed.

@SleepWalker
Copy link
Contributor Author

@endiliey, @ericnakagawa I have a question about next/prev links at the page bottom in case, when we are using Object with href and label to define the sidebar link. In this case the link may point outside current site.

Should the next/prev navigation include this link or should we skip the link and point to the document next (or previous) to the link?

@endiliey
Copy link
Contributor

Cc @JoelMarcey @yangshun

@JoelMarcey
Copy link
Contributor

@SleepWalker Hi 👋 Can you provide an example where you may have an external link from an internal doc page?

That said, if that was to happen, I believe either:

  1. Link to the external site, but open in a new tab.
  2. Link to the next available internal doc

I think we should, at the very least, avoid closing the current site all together.

@SleepWalker
Copy link
Contributor Author

@JoelMarcey That's a request from #827. It can be that the link will point to the same domain, but that may be a page outside of Docusaurus context (e.g. auto-generated API docs with their own layout and navigation).

So which of the two options are better? The second one looks better to me

@JoelMarcey
Copy link
Contributor

@SleepWalker Thanks for the context.

Yeah, I am ok with option 2.

@yangshun yangshun removed the status: claimed Issue has been claimed by a contributor who plans to work on it. label Oct 14, 2018
SleepWalker added a commit to SleepWalker/Docusaurus that referenced this issue Oct 20, 2018
SleepWalker added a commit to SleepWalker/Docusaurus that referenced this issue Oct 20, 2018
SleepWalker added a commit to SleepWalker/Docusaurus that referenced this issue Oct 20, 2018
@SleepWalker
Copy link
Contributor Author

re-claimed :)

@yangshun yangshun added the status: claimed Issue has been claimed by a contributor who plans to work on it. label Oct 21, 2018
@yangshun
Copy link
Contributor

@SleepWalker it's yours!

I've added an "issue: claimed" label so that others will know not to start work on the issue. If you change your mind about the issue, no worries! Just let me know so that I can remove the label and free it up for someone else to claim.

I'll check in with you periodically so that we can keep the task updated with the progress.

@endiliey endiliey removed the status: claimed Issue has been claimed by a contributor who plans to work on it. label May 17, 2019
@endiliey endiliey added the 2.x label Jul 18, 2019
@endiliey
Copy link
Contributor

endiliey commented Oct 7, 2019

#1812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

No branches or pull requests

4 participants