docsify/docs/configuration.md

371 lines
5.9 KiB
Markdown
Raw Normal View History

2017-02-13 22:43:58 +08:00
# Configuration
2018-02-11 19:49:50 +08:00
You can configure the `window.$docsify`.
2017-02-13 22:43:58 +08:00
```html
<script>
window.$docsify = {
repo: 'QingWei-Li/docsify',
maxLevel: 3,
coverpage: true
}
</script>
```
## el
2018-02-11 19:49:50 +08:00
* Type: `String`
* Default: `#app`
2017-02-13 22:43:58 +08:00
The DOM element to be mounted on initialization. It can be a CSS selector string or an actual HTMLElement.
```js
window.$docsify = {
el: '#app'
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## repo
2018-02-11 19:49:50 +08:00
* Type: `String`
* Default: `null`
2017-02-13 22:43:58 +08:00
Configure the repository url or a string of `username/repo` can add the [GitHub Corner](http://tholman.com/github-corners/) widget in the top right corner of the site.
```js
window.$docsify = {
repo: 'QingWei-Li/docsify',
// or
repo: 'https://github.com/QingWei-Li/docsify/'
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## maxLevel
2017-02-13 22:43:58 +08:00
2018-02-11 19:49:50 +08:00
* Type: `Number`
* Default: `6`
2017-02-13 22:43:58 +08:00
Maximum Table of content level.
```js
window.$docsify = {
maxLevel: 4
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## loadNavbar
2017-02-13 22:43:58 +08:00
2018-02-11 19:49:50 +08:00
* Type: `Boolean|String`
* Default: `false`
2017-02-13 22:43:58 +08:00
2017-03-10 05:19:07 +08:00
Loads navbar from the Markdown file `_navbar.md` if **true**, or else from the path specified.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
// load from _navbar.md
loadNavbar: true,
// load from nav.md
loadNavbar: 'nav.md'
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## loadSidebar
2017-02-13 22:43:58 +08:00
2018-02-11 19:49:50 +08:00
* Type: `Boolean|String`
* Default: `false`
2017-02-13 22:43:58 +08:00
2017-03-10 05:19:07 +08:00
Loads sidebar from the Markdown file `_sidebar.md` if **true**, or else from the path specified.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
// load from _sidebar.md
loadSidebar: true,
// load from summary.md
loadSidebar: 'summary.md'
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## subMaxLevel
2017-02-13 22:43:58 +08:00
2018-02-11 19:49:50 +08:00
* Type: `Number`
* Default: `0`
2017-02-13 22:43:58 +08:00
2017-03-10 05:19:07 +08:00
Add table of contents (TOC) in custom sidebar.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2017-02-19 00:11:16 +08:00
subMaxLevel: 2
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## auto2top
2018-02-11 19:49:50 +08:00
* Type: `Boolean`
* Default: `false`
2017-02-13 22:43:58 +08:00
Scrolls to the top of the screen when the route is changed.
```js
window.$docsify = {
auto2top: true
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## homepage
2018-02-11 19:49:50 +08:00
* Type: `String`
* Default: `README.md`
2017-02-13 22:43:58 +08:00
`README.md` in your docs folder will be treated as homepage for your website, but sometimes you may need to serve another file as your homepage.
```js
window.$docsify = {
// Change to /home.md
homepage: 'home.md',
// Or use the readme in your repo
2018-02-11 19:49:50 +08:00
homepage:
'https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md'
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## basePath
2017-02-13 22:43:58 +08:00
2018-02-11 19:49:50 +08:00
* Type: `String`
2017-02-13 22:43:58 +08:00
Base path of the website. You can set it to another directory or another domain name.
```js
window.$docsify = {
basePath: '/path/',
// Load the files from another site
basePath: 'https://docsify.js.org/',
// Even can load files from other repo
2018-02-11 19:49:50 +08:00
basePath:
'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/'
};
2017-02-13 22:43:58 +08:00
```
## coverpage
2018-02-11 19:49:50 +08:00
* Type: `Boolean|String`
* Default: `false`
2017-02-13 22:43:58 +08:00
2017-03-25 15:52:21 +08:00
Activate the [cover feature](cover.md). If true, it will load from `_coverpage.md`.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
coverpage: true,
// Custom file name
coverpage: 'cover.md'
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## name
2018-02-11 19:49:50 +08:00
* Type: `String`
2017-02-13 22:43:58 +08:00
2017-03-10 05:19:07 +08:00
Website name as it appears in the sidebar.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
name: 'docsify'
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## nameLink
2017-02-13 22:43:58 +08:00
2018-02-11 19:49:50 +08:00
* Type: `String`
* Default: `window.location.pathname`
2017-02-13 22:43:58 +08:00
The name of the link.
```js
window.$docsify = {
2017-02-28 20:57:32 +08:00
nameLink: '/',
// For each route
nameLink: {
'/zh-cn/': '/zh-cn/',
'/': '/'
}
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## markdown
2018-02-11 19:49:50 +08:00
* Type: `Function`
2017-02-13 22:43:58 +08:00
2017-03-25 15:52:21 +08:00
See [Markdown configuration](markdown.md).
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2017-02-19 00:11:16 +08:00
// object
markdown: {
smartypants: true,
renderer: {
link: function() {
// ...
}
}
},
// function
2018-02-11 19:49:50 +08:00
markdown: function(marked, renderer) {
2017-02-13 22:43:58 +08:00
// ...
2018-02-11 19:49:50 +08:00
return marked;
2017-02-13 22:43:58 +08:00
}
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## themeColor
2017-02-13 22:43:58 +08:00
2018-02-11 19:49:50 +08:00
* Type: `String`
2017-02-13 22:43:58 +08:00
2017-03-10 05:19:07 +08:00
Customize the theme color. Use [CSS3 variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) feature and polyfill in old browser.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
themeColor: '#3F51B5'
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## alias
2018-02-11 19:49:50 +08:00
* Type: `Object`
2017-02-13 22:43:58 +08:00
2017-07-10 22:23:09 +08:00
Set the route alias. You can freely manage routing rules. Supports RegExp.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
alias: {
2017-07-10 22:23:09 +08:00
'/foo/(+*)': '/bar/$1', // supports regexp
2017-02-13 22:43:58 +08:00
'/zh-cn/changelog': '/changelog',
2018-02-11 19:49:50 +08:00
'/changelog':
'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG',
2017-12-14 09:40:29 +08:00
'/.*/_sidebar.md': '/_sidebar.md' // See #301
2017-02-13 22:43:58 +08:00
}
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2017-02-18 22:12:17 +08:00
2018-02-11 19:49:50 +08:00
## autoHeader
2017-02-18 22:12:17 +08:00
2018-02-11 19:49:50 +08:00
* type: `Boolean`
2017-02-18 22:12:17 +08:00
2017-03-10 05:19:07 +08:00
If `loadSidebar` and `autoHeader` are both enabled, for each link in `_sidebar.md`, prepend a header to the page before converting it to html. Compare [#78](https://github.com/QingWei-Li/docsify/issues/78).
2017-02-18 22:12:17 +08:00
```js
window.$docsify = {
loadSidebar: true,
autoHeader: true
2018-02-11 19:49:50 +08:00
};
2017-02-18 22:12:17 +08:00
```
2017-02-18 23:04:52 +08:00
2018-02-11 19:49:50 +08:00
## executeScript
2017-02-18 23:04:52 +08:00
2018-02-11 19:49:50 +08:00
* type: `Boolean`
2017-02-18 23:04:52 +08:00
2018-02-11 19:49:50 +08:00
Execute the script on the page. Only parse the first script tag([demo](themes)). If Vue is present, it is turned on by default.
2017-02-18 23:04:52 +08:00
```js
window.$docsify = {
executeScript: true
2018-02-11 19:49:50 +08:00
};
2017-02-18 23:04:52 +08:00
```
```markdown
## This is test
<script>
console.log(2333)
</script>
```
2017-03-25 15:52:21 +08:00
Note that if you are running an external script, e.g. an embedded jsfiddle demo, make sure to include the [external-script](plugins.md?id=external-script) plugin.
2017-03-11 19:30:38 +08:00
2018-02-11 19:49:50 +08:00
## noEmoji
2017-03-11 19:30:38 +08:00
2018-02-11 19:49:50 +08:00
* type: `Boolean`
2017-07-10 22:23:09 +08:00
2017-03-11 19:30:38 +08:00
Disabled emoji parse.
```js
window.$docsify = {
noEmoji: true
2018-02-11 19:49:50 +08:00
};
2017-03-11 19:30:38 +08:00
```
2018-02-11 19:49:50 +08:00
## mergeNavbar
2018-02-11 19:49:50 +08:00
* type: `Boolean`
2017-07-10 22:23:09 +08:00
Navbar will be merged with the sidebar on smaller screens.
```js
window.$docsify = {
mergeNavbar: true
2018-02-11 19:49:50 +08:00
};
```
2017-05-16 23:03:22 +08:00
2018-02-11 19:49:50 +08:00
## formatUpdated
2017-07-10 22:23:09 +08:00
2018-02-11 19:49:50 +08:00
* type: `String|Function`
2017-07-10 22:23:09 +08:00
2017-05-30 12:05:25 +08:00
We can display the file update date through **{docsify-updated<span>}</span>** variable. And format it by `formatUpdated`.
2017-05-16 23:03:22 +08:00
See https://github.com/lukeed/tinydate#patterns
2018-02-11 19:49:50 +08:00
2017-05-16 23:03:22 +08:00
```js
window.$docsify = {
formatUpdated: '{MM}/{DD} {HH}:{mm}',
2018-02-11 19:49:50 +08:00
formatUpdated: function(time) {
2017-05-16 23:03:22 +08:00
// ...
2018-02-11 19:49:50 +08:00
return time;
2017-05-16 23:03:22 +08:00
}
2018-02-11 19:49:50 +08:00
};
2017-05-16 23:03:22 +08:00
```
2018-02-11 19:49:50 +08:00
## externalLinkTarget
2018-02-11 19:49:50 +08:00
* type: `String`
* default: `_blank`
2017-07-10 22:23:09 +08:00
Target to open external links. Default `'_blank'` (new window/tab)
```js
window.$docsify = {
externalLinkTarget: '_self' // default: '_blank'
2018-02-11 19:49:50 +08:00
};
```
2017-05-30 12:05:25 +08:00
2018-02-11 19:49:50 +08:00
## routerMode
2017-07-10 22:23:09 +08:00
2018-02-11 19:49:50 +08:00
* type: `String`
* default: `history`
2017-07-10 22:23:09 +08:00
2017-05-30 12:05:25 +08:00
```js
window.$docsify = {
routerMode: 'history' // default: 'hash'
2018-02-11 19:49:50 +08:00
};
2017-05-30 12:05:25 +08:00
```
## noCompileLinks
2018-02-11 19:49:50 +08:00
* type: `Array`
Sometimes we do not want docsify to handle our links. See [#203](https://github.com/QingWei-Li/docsify/issues/203)
```js
window.$docsify = {
2018-02-11 19:49:50 +08:00
noCompileLinks: ['/foo', '/bar/.*']
};
```
2018-02-11 19:49:50 +08:00
##