2017-02-13 22:43:58 +08:00
# Configuration
2017-03-10 05:19:07 +08:00
**docsify** supports two different ways of configuration. You can configure the `window.$docsify` or write configuration on the script tag via `data-*` attributes.
2017-02-13 22:43:58 +08:00
```html
<!-- by $docsify -->
< script >
window.$docsify = {
repo: 'QingWei-Li/docsify',
maxLevel: 3,
coverpage: true
}
< / script >
<!-- or data - * -->
< script
src="//unpkg.com/docsify"
data-repo="QingWei-Li/docsify"
data-max-level="3"
data-coverpage>
< / script >
```
Both ways are compatible. However, the first way is recommended. It is clear and can be configured in a separate file.
!> In `window.$docsfiy` , the options should be written by camelCase.
## el
- Type: `String`
- Default: `#app`
The DOM element to be mounted on initialization. It can be a CSS selector string or an actual HTMLElement.
```js
window.$docsify = {
el: '#app'
}
```
## repo
- Type: `String`
- Default: `null`
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/'
}
```
## max-level
- Type: `Number`
- Default: `6`
Maximum Table of content level.
```js
window.$docsify = {
maxLevel: 4
}
```
## load-navbar
- Type: `Boolean|String`
- Default: `false`
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'
}
```
## load-sidebar
- Type: `Boolean|String`
- Default: `false`
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'
}
```
## sub-max-level
- Type: `Number`
- Default: `0`
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
2017-02-13 22:43:58 +08:00
}
```
## auto2top
- Type: `Boolean`
- Default: `false`
Scrolls to the top of the screen when the route is changed.
```js
window.$docsify = {
auto2top: true
}
```
## homepage
- Type: `String`
- Default: `README.md`
`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
homepage: 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md'
}
```
## base-path
- Type: `String`
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
basePath: 'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/'
}
```
## coverpage
- Type: `Boolean|String`
- Default: `false`
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'
}
```
## name
- Type: `String`
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'
}
```
## name-link
- Type: `String`
- Default: `window.location.pathname`
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/',
'/': '/'
}
2017-02-13 22:43:58 +08:00
}
```
## markdown
- Type: `Function`
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
2017-02-13 22:43:58 +08:00
markdown: function (marked, renderer) {
// ...
return marked
}
}
```
## theme-color
- Type: `String`
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'
}
```
## alias
- Type: `Object`
Set the route alias. You can freely manage routing rules.
```js
window.$docsify = {
alias: {
'/zh-cn/changelog': '/changelog',
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
}
}
```
2017-02-18 22:12:17 +08:00
## auto-header
- type: `Boolean`
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
}
```
2017-02-18 23:04:52 +08:00
## execute-script
- type: `Boolean`
Execute the script on the page. Only parse the first script tag([demo](themes)). If Vue is present, it is turned on by default.
```js
window.$docsify = {
executeScript: true
}
```
```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
## no-emoji
Disabled emoji parse.
```js
window.$docsify = {
noEmoji: true
}
```
2017-04-09 12:10:37 +08:00
## merge-navbar
Navbar will be merged with the sidebar on smaller screens.
```js
window.$docsify = {
mergeNavbar: true
}
```
2017-05-16 23:03:22 +08:00
## format-updated
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
```js
window.$docsify = {
formatUpdated: '{MM}/{DD} {HH}:{mm}',
formatUpdated: function (time) {
// ...
return time
}
}
```
2017-05-16 23:09:41 +08:00
## external-link-target
2017-06-16 16:14:23 +08:00
Target to open external links. Default `'_blank'` (new window/tab)
2017-05-16 23:09:41 +08:00
```js
window.$docsify = {
externalLinkTarget: '_self' // default: '_blank'
}
```
2017-05-30 12:05:25 +08:00
## router-mode
```js
window.$docsify = {
routerMode: 'history' // default: 'hash'
}
```