docsify/docs/more-pages.md

93 lines
2.7 KiB
Markdown
Raw Normal View History

2017-02-13 22:43:58 +08:00
# More pages
If you need more pages, you can simply create more markdown files in your docsify directory. If you create a file named `guide.md`, then it is accessible via `/#/guide`.
2017-02-13 22:43:58 +08:00
For example, the directory structure is as follows:
```text
.
2017-05-22 02:45:43 +08:00
└── docs
├── README.md
├── guide.md
└── zh-cn
├── README.md
└── guide.md
2017-02-13 22:43:58 +08:00
```
Matching routes
```text
docs/README.md => http://domain.com
docs/guide.md => http://domain.com/guide
docs/zh-cn/README.md => http://domain.com/zh-cn/
docs/zh-cn/guide.md => http://domain.com/zh-cn/guide
```
## Custom sidebar
2017-02-21 14:05:58 +08:00
By default, the table of contents in the sidebar is automatically generated based on your markdown files. If you need a custom sidebar, then you can create your own `_sidebar.md` (see [this documentation's sidebar](https://github.com/QingWei-Li/docsify/blob/master/docs/_sidebar.md) for an example):
2017-02-13 22:43:58 +08:00
2017-03-25 15:52:21 +08:00
First, you need to set `loadSidebar` to **true**. Details are available in the [configuration paragraph](configuration.md#load-sidebar).
2017-02-13 22:43:58 +08:00
```html
<!-- index.html -->
2017-02-13 22:43:58 +08:00
<script>
window.$docsify = {
loadSidebar: true
}
</script>
2017-03-10 05:19:07 +08:00
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
2017-02-13 22:43:58 +08:00
```
Create the `_sidebar.md`:
2017-02-13 22:43:58 +08:00
```markdown
<!-- docs/_sidebar.md -->
2017-02-13 22:43:58 +08:00
- [Home](/)
2017-03-25 15:52:21 +08:00
- [Guide](guide.md)
2017-02-13 22:43:58 +08:00
```
!> You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
2017-02-13 22:43:58 +08:00
`_sidebar.md` is loaded from each level directory. If the current directory doesn't have `_sidebar.md`, it will fall back to the parent directory. If, for example, the current path is `/guide/quick-start`, the `_sidebar.md` will be loaded from `/guide/_sidebar.md`.
2017-02-13 22:43:58 +08:00
## Table of Contents
2017-03-25 15:52:21 +08:00
A custom sidebar can also automatically generate a table of contents by setting a `subMaxLevel`, compare [sub-max-level configuration](configuration.md#sub-max-level).
2017-02-13 22:43:58 +08:00
```html
<!-- index.html -->
2017-02-13 22:43:58 +08:00
<script>
window.$docsify = {
loadSidebar: true,
subMaxLevel: 2
}
</script>
2017-03-10 05:19:07 +08:00
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
```
## Ignoring Subheaders
When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `{docsify-ignore}` to it.
```markdown
# Getting Started
## Header {docsify-ignore}
This header won't appear in the sidebar table of contents.
```
To ignore all headers on a specific page, you can use `{docsify-ignore-all}` on the first header of the page.
```markdown
# Getting Started
## Header {docsify-ignore-all}
This header won't appear in the sidebar table of contents.
```
Both `{docsify-ignore}` and `{docsify-ignore-all}` will not be rendered on the page when used.