Skip to content

Better sidebar markup: distinguish content with and without sub sections. #1181

Closed
@trusktr

Description

@trusktr

I've been working on my site, gathering ideas.

Feature request

Improvement of markup so that we know if a menu item will have sub-menu items.

What problem does this feature solve?

Currently, Docsify assumes that every top-level menu item must have sub-content, so therefore docsify-themeable styles the meny items with the open/close icons. There's no way for docsify-themeable to know if a menu item should not be open/close-able.

What does the proposed API look like?

Somehow, the markup should convey whether the menu items will be collapsible or not. This would perhaps add classes in the markup.

How should this be implemented in your opinion?

There's no way for the client-side engine to know ahead of time whether a page will have sub-sections, or not.

Perhaps the only way to do this currently, would be to provide a configuration option, like

window.$docsify = {
  nonCollapsibleMenuItems: [
    './foo/m.md',
    'google.com',
  ]
}

Or maybe, we can expand on the sidebar markdown parser to detect a certain syntax (like Docsify does with other links) to tell it which ones are not collapsible:

- [Foo](./foo.md ':no-collapse') 

I think I like the markdown idea more.

This is what my sidebar markdown looks like:

-   **Guide**

    -   [Install](/install.md)
    -   [Workflows](/workflows.md)

-   **Examples**

    -   [Hello 3D](/examples/hello3d.md)
    -   [Hello 3D, Parent Transforms](/examples/hello3d-parent-transforms.md)
    -   [Ripple flip](/examples/ripple-flip.md)
    -   [Autolayout (declarative)](/examples/autolayout-declarative.md)
    -   [Autolayout (imperative)](/examples/autolayout-imperative.md)
    -   [Morphing spiral](/examples/spiral.md)
    -   [obj-model](/examples/obj-model.md)
    -   [Buttons with shadow](/examples/buttons-with-shadow.md)
    -   [material-texture](/examples/material-texture.md)
    -   [Origin](/examples/origin.md)

-   **API Reference**
    <!-- __API_AUTOGENERATED_BEGIN__ -->
  - components/
    - [Cube](/api/components/Cube.md)
  - core/
    - [ImperativeBase](/api/core/ImperativeBase.md)
    - [Node](/api/core/Node.md)
    - [TreeNode](/api/core/TreeNode.md)
  - html/
    - [WithUpdate](/api/html/WithUpdate.md)

<!-- __API_AUTOGENERATED_END__ -->

And this is currently what it looks like (work in progress):

current-sidebar

The items under Examples are all non-collapsible, so I'd like to remove the collapse icons from those. They are the docsify-themeable icons (@jhildenbiddle).

What are your thoughts on how to handle this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions