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

Proposal: auto generate sidebar #1290

Open
anikethsaha opened this issue Jul 17, 2020 · 9 comments
Open

Proposal: auto generate sidebar #1290

anikethsaha opened this issue Jul 17, 2020 · 9 comments
Assignees
Labels
enhancement pinned This is to pinned the PR/Issue in order to keep it open

Comments

@anikethsaha
Copy link
Member

Auto-generate sidebar

Summary

Auto-generate and update the sidebar i.e _sidebar.md by looking into the folders/files

Motivation

If you have a big project or a project having many markdown files. It is kind of extra work look for each file and writes the path and the file name and the text to display it.
Maximum projects I have seen take each .md file as a single page and .md files under a folder inside the docs directory is a sub-page. So if we go with usual lookups through each file/folder. This is quite easy to achieve.

Detailed Design

No changes are required in the core. Only needs changes in cli. New command probably

If we have directories like this

|- <root>
       |- README.md
       |- index.html
       |- _sidebar.md
       |- a.md
       |- guide
            |- guide-a.md
       |- b.md

The sidebar command should generate the following

- [a](./a.md)
- guide
  - [a](./guide/guide-a.md)
- [b](./b.md)

We need to traverse through the directory and create an object or tree and then just print the tree as a list in the markdown.

Documentation

Update the docs in the main docs site as a separate page and create docs for the command in the cli and do a remote rendering of the page in the main docs

Drawbacks

Few

  • It won't know whether markdown file should be in the heading or in subheading if it goes out of our prediction.
  • cant do the operation for the .html files.

Backwards Compatibility Analysis

Not required as no changes in the core is being done.

Alternatives

Do the manual entry in the _sidebar.md

Open Questions

  • Should we wait for or put this in v5 ?
  • Any volunteers for taking this ?

Help Needed

None.

Frequently Asked Questions

None

Related Discussions

Couldnt find any.

@anikethsaha anikethsaha pinned this issue Jul 17, 2020
@anikethsaha anikethsaha added enhancement pinned This is to pinned the PR/Issue in order to keep it open labels Jul 17, 2020
@ghost

This comment has been minimized.

@ajboni
Copy link

ajboni commented Aug 5, 2020

This would be very useful.
I think you will also need some sort of rule for ordering/ignoring the entries, with a prefix on the filename or some front-matter maybe.

|- <root>
       |- README.md
       |- index.html
       |- _sidebar.md
       |- 1__a.md
       |- 3__guide
            | no_prefix.md  // => Fallback  alphabetical sort
            |- 1__guide-a.md
            |- __ignore.md
       |- 2__b.md

result

- [a](./a.md)
- [b](./b.md)
- guide
  - [a](./guide/guide-a.md)
  - [no_prefix](./guide/no_prefix.md)

@equinusocio
Copy link
Contributor

equinusocio commented Sep 5, 2020

Personally, I think this can be limiting and it should be optional. For example, we like that sidebars are just markdown files and we can customize it and swap it (for multilanguage docs, etc). Also, we think that sidebars that are not related to the file structure can be more useful in some situations.

This is how our sidebar looks. We added emoticons and custom HTML badges beside titles. Such level of customizations should be preserved and so, the auto-generated sidebar must be opt-in or at least, opt-out.

Screenshot 2020-09-05 at 12 20 26

@ghost

This comment has been minimized.

@randomor
Copy link

randomor commented Jun 5, 2021

This would be so nice! No need to update two places and everything are inferred with convention. Most of the time the directories are organized with the files anyway, if not, there is always extra cognitive load. This can be an opt-in option and would also allow the existing _sidebar.md to override if it exists so existing users can adopt it incrementally in select directories. ❤️❤️❤️

@fangyuqiang
Copy link

We need this! please!

@Anilople
Copy link
Contributor

Here is my way to generate sidebar.

I write java code to do it.

The code in .zip file Generator.zip

Download it to docsify's directory which contains .md files. And unzip it.

unzip Generator.zip

Compile java code by javac

javac -encoding UTF-8 Generator.java

Generate sidebar to stdout

java Generator build-sidebar .

@trusktr
Copy link
Member

trusktr commented Jan 26, 2022

@sy-records already added an initial version of this to docsify cli in docsifyjs/docsify-cli#130

Sy, can you update the docs here for docsify.js.org? (might be a good reason to have cli in the same repo, so we can update the docs in the same pull request, etc).

@sy-records
Copy link
Member

Ok, I will add it later.

Added it in docsify-cli before

see https://github.com/docsifyjs/docsify-cli#generate-command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pinned This is to pinned the PR/Issue in order to keep it open
Projects
None yet
Development

No branches or pull requests

8 participants