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

Auto header for each page #78

Closed
liulex opened this issue Feb 14, 2017 · 3 comments
Closed

Auto header for each page #78

liulex opened this issue Feb 14, 2017 · 3 comments

Comments

@liulex
Copy link
Contributor

liulex commented Feb 14, 2017

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://raw.githubusercontent.com/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.

@liulex
Copy link
Contributor Author

liulex commented Feb 19, 2017

Thanks! Now I only need to maintain the wiki pages! 🎉🎉🎉

@QingWei-Li
Copy link
Member

Cool. Good idea!

If you put all the pages on the wiki, you only need to configure the basePath.

$docsify = {
  basePath: 'https://raw.githubusercontent.com/wiki/liulex/Snipaste-Feedback/'
}

@liulex
Copy link
Contributor Author

liulex commented Feb 19, 2017

I tried, but I cannot alias the sidebar. The following config does not work:

$docsify = {
  alias: {
      '/zh-cn/_sidebar': 'sidebar_zh.md'
  }
}

And since the file names of Github Wiki are case-sensitive, I would still need to write some aliases after I set basePath. So I am satisfied the current configs. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants