Skip to content

Auto header for each page #78

@liulex

Description

@liulex

Take docisfy as an example:

With loadSidebar enabled, in docs/_sidebar.md, we have:

- Getting started
 - [Quick start](/quickstart)
 - [Writing more pages](/more-pages)
 - [Custom navbar](/custom-navbar)
 - [Cover page](/cover)

...

The first line of /quickstart is # Quick start, and the first line of /custom-navbar is # Custom navbar, etc.
It would be great if we do not have to manually write these lines, since they can be inferred from the sidebar.

It has 3 advantages at least:

  • Save a line in each subpage, of course.
  • Whenever we want to change the header for a subpage, we only need to modify it in the sidebar, not both places. And the inconsistency can be avoided naturally.
    • For example, at the moment, docsify has Writing more pages for /more-pages in the sidebar, while the first line of /more-pages.md is More pages. Such inconsistency may not be desireable.
  • Be consistent with the behavior of Github Wiki.
    • In Github Wiki, a page named Changelog, which is actually a file Changelog.md, will have the header 'Changelog' automatically. We do not have to add a line # Changelog in the content. See here for an example.
    • If this feature is implemented, we will be able to directly use Github Wiki for docsify. For example, the md file for the link above is 'https://github.com/ghraw/wiki/liulex/Snipaste-Feedback/Changelog.md'. We can alias /Changelog to it. Then we can have a Github Wiki (for community edit) and a doscify generated site at the same time!

In case I haven't made myself clear, the logic of this feature (maybe named autoHeader) is:

If loadSidebar and autoHeader are both enabled, for each link in _sidebar.md, prepend a header to the page before converting it to html.

For example, if [Quick start](/quickstart) is in _sidebar.md, we prepend a line # Quick start into /quickstart.md before we render /quickstart.md into html.

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