question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature request] sidebar item add collapse and expand

See original GitHub issue

Appreciate for the work of this project.

I know it seems rule to ask for such feature and maybe it is “impossible” to implement. But, how if user provides directories structure in _sidebar.md file.

for example _sidebar.md

- FolderName
  - [Article1](/FolderName/Article1.md)
  - [Article2](/FolderName/Article2.md)
- FolderName2
  - [Article3](/FolderName2/Article3.md)
  - [Article4](/FolderName2/Article4.md)

The original demand comes from that i want to construct my personal blog with doscify. However, the sidebar is as long as my article amount.

I found that i can write a bash script to help me scan my folders and then generate a sidebar file. such as find . -mindepth 2 -name "*.md" | awk -F'/' 'BEGIN {RS=".md"} {arr[$2]=arr[$2]"\n - ["$3"](/"$2"/"$3")"} END {for (key in arr) print "- "key, arr[key]}' > _sidebar.md what’s more, travis ci can help us do such a job.

so, can docsify add a toggle feature for no hyperlink item in the sidebar? it is ok for adding it into configurable options.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Wsinecommented, Jul 11, 2019

I wrote a small solution this afternoon, although it may waste more calculation resource.

window.$docsify = {
  plugins: [
    function(hook, vm) {
      hook.doneEach(function() {
        document.querySelectorAll(".sidebar-nav > ul > li").forEach(
          function(node, index, nodelist) {
            var span = document.createElement("span");
            span.innerHTML = node.firstChild.data;
            span.style.cursor = "pointer";
            span.onclick = function(event) {
              var ul = event.target.nextElementSibling;
              if (ul.style.display === "none") {
                ul.style.display = "block";
              } else {
                ul.style.display = "none";
              }
            };
            node.firstChild.replaceWith(span);
            node.lastChild.style.display = "none";
        });
        var active = document.querySelector(".sidebar-nav li.active");
        if (active) {
          active.parentElement.style.display = "block";
        }
      });
    }
  ]
}

there is also a live demo. => https://wsine.github.io/blog

1reaction
vagracommented, Apr 19, 2020

very good!

view my site: https://kepan.org/docsify

i have many heading levels (up to 108), i want the sidebar items can be expand & collapse.

like Typora’s side bar, that’s very good! it can expand, collapse, and sync scroll.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - [feature request] sidebar item add collapse and expand -
I know it seems rule to ask for such feature and maybe it is "impossible" to implement. But, how if user provides directories...
Read more >
Collapse / expand all sections button in sidebar - Docusaurus
Having a collapse/expand all button towards the top of the sidebar would improve usability and discoverability, while also simplifying sidebars with too ...
Read more >
Sidebar - Docusaurus
sidebar.autoCollapseCategories option would collapse all sibling categories when expanding one category. This saves the user from having too ...
Read more >
Add 'Expand Folder and Subfolders' Option in Sidebar Menu
This isn't very convenient for some Linux users who use this combination for moving windows. I suggest adding this functionality as an option...
Read more >
Configure API docs functionality - Redocly
If set to true , selecting an expanded item in the sidebar twice will collapse it. Supported in Redoc CE. mockServer. object. Allows...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found