docs: update config

This commit is contained in:
qingwei.li 2018-02-11 19:49:50 +08:00 • committed by cinwell.li
commit bd7ee84241
3 changed files with 302 additions and 302 deletions

View file

@ -1,9 +1,8 @@
# Configuration # Configuration
**docsify** supports two different ways of configuration. You can configure the `window.$docsify` or write configuration on the script tag via `data-*` attributes. You can configure the `window.$docsify`.
```html ```html
<!-- by $docsify -->
<script> <script>
window.$docsify = { window.$docsify = {
repo: 'QingWei-Li/docsify', repo: 'QingWei-Li/docsify',
@ -11,37 +10,25 @@
coverpage: true coverpage: true
} }
</script> </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 ## el
- Type: `String` * Type: `String`
- Default: `#app` * Default: `#app`
The DOM element to be mounted on initialization. It can be a CSS selector string or an actual HTMLElement. The DOM element to be mounted on initialization. It can be a CSS selector string or an actual HTMLElement.
```js ```js
window.$docsify = { window.$docsify = {
el: '#app' el: '#app'
} };
``` ```
## repo ## repo
- Type: `String` * Type: `String`
- Default: `null` * 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. 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.
@ -50,26 +37,26 @@ window.$docsify = {
repo: 'QingWei-Li/docsify', repo: 'QingWei-Li/docsify',
// or // or
repo: 'https://github.com/QingWei-Li/docsify/' repo: 'https://github.com/QingWei-Li/docsify/'
} };
``` ```
## max-level ## maxLevel
- Type: `Number` * Type: `Number`
- Default: `6` * Default: `6`
Maximum Table of content level. Maximum Table of content level.
```js ```js
window.$docsify = { window.$docsify = {
maxLevel: 4 maxLevel: 4
} };
``` ```
## load-navbar ## loadNavbar
- Type: `Boolean|String` * Type: `Boolean|String`
- Default: `false` * Default: `false`
Loads navbar from the Markdown file `_navbar.md` if **true**, or else from the path specified. Loads navbar from the Markdown file `_navbar.md` if **true**, or else from the path specified.
@ -80,13 +67,13 @@ window.$docsify = {
// load from nav.md // load from nav.md
loadNavbar: 'nav.md' loadNavbar: 'nav.md'
} };
``` ```
## load-sidebar ## loadSidebar
- Type: `Boolean|String` * Type: `Boolean|String`
- Default: `false` * Default: `false`
Loads sidebar from the Markdown file `_sidebar.md` if **true**, or else from the path specified. Loads sidebar from the Markdown file `_sidebar.md` if **true**, or else from the path specified.
@ -97,39 +84,39 @@ window.$docsify = {
// load from summary.md // load from summary.md
loadSidebar: 'summary.md' loadSidebar: 'summary.md'
} };
``` ```
## sub-max-level ## subMaxLevel
- Type: `Number` * Type: `Number`
- Default: `0` * Default: `0`
Add table of contents (TOC) in custom sidebar. Add table of contents (TOC) in custom sidebar.
```js ```js
window.$docsify = { window.$docsify = {
subMaxLevel: 2 subMaxLevel: 2
} };
``` ```
## auto2top ## auto2top
- Type: `Boolean` * Type: `Boolean`
- Default: `false` * Default: `false`
Scrolls to the top of the screen when the route is changed. Scrolls to the top of the screen when the route is changed.
```js ```js
window.$docsify = { window.$docsify = {
auto2top: true auto2top: true
} };
``` ```
## homepage ## homepage
- Type: `String` * Type: `String`
- Default: `README.md` * 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. `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.
@ -139,13 +126,14 @@ window.$docsify = {
homepage: 'home.md', homepage: 'home.md',
// Or use the readme in your repo // Or use the readme in your repo
homepage: 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md' homepage:
} 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md'
};
``` ```
## base-path ## basePath
- Type: `String` * Type: `String`
Base path of the website. You can set it to another directory or another domain name. Base path of the website. You can set it to another directory or another domain name.
@ -157,14 +145,15 @@ window.$docsify = {
basePath: 'https://docsify.js.org/', basePath: 'https://docsify.js.org/',
// Even can load files from other repo // Even can load files from other repo
basePath: 'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/' basePath:
} 'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/'
};
``` ```
## coverpage ## coverpage
- Type: `Boolean|String` * Type: `Boolean|String`
- Default: `false` * Default: `false`
Activate the [cover feature](cover.md). If true, it will load from `_coverpage.md`. Activate the [cover feature](cover.md). If true, it will load from `_coverpage.md`.
@ -174,25 +163,25 @@ window.$docsify = {
// Custom file name // Custom file name
coverpage: 'cover.md' coverpage: 'cover.md'
} };
``` ```
## name ## name
- Type: `String` * Type: `String`
Website name as it appears in the sidebar. Website name as it appears in the sidebar.
```js ```js
window.$docsify = { window.$docsify = {
name: 'docsify' name: 'docsify'
} };
``` ```
## name-link ## nameLink
- Type: `String` * Type: `String`
- Default: `window.location.pathname` * Default: `window.location.pathname`
The name of the link. The name of the link.
@ -205,12 +194,12 @@ window.$docsify = {
'/zh-cn/': '/zh-cn/', '/zh-cn/': '/zh-cn/',
'/': '/' '/': '/'
} }
} };
``` ```
## markdown ## markdown
- Type: `Function` * Type: `Function`
See [Markdown configuration](markdown.md). See [Markdown configuration](markdown.md).
@ -229,26 +218,26 @@ window.$docsify = {
// function // function
markdown: function(marked, renderer) { markdown: function(marked, renderer) {
// ... // ...
return marked return marked;
}
} }
};
``` ```
## theme-color ## themeColor
- Type: `String` * Type: `String`
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. 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.
```js ```js
window.$docsify = { window.$docsify = {
themeColor: '#3F51B5' themeColor: '#3F51B5'
} };
``` ```
## alias ## alias
- Type: `Object` * Type: `Object`
Set the route alias. You can freely manage routing rules. Supports RegExp. Set the route alias. You can freely manage routing rules. Supports RegExp.
@ -257,15 +246,16 @@ window.$docsify = {
alias: { alias: {
'/foo/(+*)': '/bar/$1', // supports regexp '/foo/(+*)': '/bar/$1', // supports regexp
'/zh-cn/changelog': '/changelog', '/zh-cn/changelog': '/changelog',
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG', '/changelog':
'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG',
'/.*/_sidebar.md': '/_sidebar.md' // See #301 '/.*/_sidebar.md': '/_sidebar.md' // See #301
} }
} };
``` ```
## auto-header ## autoHeader
- type: `Boolean` * type: `Boolean`
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). 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).
@ -273,19 +263,19 @@ If `loadSidebar` and `autoHeader` are both enabled, for each link in `_sidebar.m
window.$docsify = { window.$docsify = {
loadSidebar: true, loadSidebar: true,
autoHeader: true autoHeader: true
} };
``` ```
## execute-script ## executeScript
- type: `Boolean` * 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. 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 ```js
window.$docsify = { window.$docsify = {
executeScript: true executeScript: true
} };
``` ```
```markdown ```markdown
@ -298,36 +288,37 @@ window.$docsify = {
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. 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.
## no-emoji ## noEmoji
- type: `Boolean` * type: `Boolean`
Disabled emoji parse. Disabled emoji parse.
```js ```js
window.$docsify = { window.$docsify = {
noEmoji: true noEmoji: true
} };
``` ```
## merge-navbar ## mergeNavbar
- type: `Boolean` * type: `Boolean`
Navbar will be merged with the sidebar on smaller screens. Navbar will be merged with the sidebar on smaller screens.
```js ```js
window.$docsify = { window.$docsify = {
mergeNavbar: true mergeNavbar: true
} };
``` ```
## format-updated ## formatUpdated
- type: `String|Function` * type: `String|Function`
We can display the file update date through **{docsify-updated<span>}</span>** variable. And format it by `formatUpdated`. We can display the file update date through **{docsify-updated<span>}</span>** variable. And format it by `formatUpdated`.
See https://github.com/lukeed/tinydate#patterns See https://github.com/lukeed/tinydate#patterns
```js ```js
window.$docsify = { window.$docsify = {
formatUpdated: '{MM}/{DD} {HH}:{mm}', formatUpdated: '{MM}/{DD} {HH}:{mm}',
@ -335,49 +326,45 @@ window.$docsify = {
formatUpdated: function(time) { formatUpdated: function(time) {
// ... // ...
return time return time;
}
} }
};
``` ```
## external-link-target ## externalLinkTarget
- type: `String` * type: `String`
- default: `_blank` * default: `_blank`
Target to open external links. Default `'_blank'` (new window/tab) Target to open external links. Default `'_blank'` (new window/tab)
```js ```js
window.$docsify = { window.$docsify = {
externalLinkTarget: '_self' // default: '_blank' externalLinkTarget: '_self' // default: '_blank'
} };
``` ```
## router-mode ## routerMode
- type: `String` * type: `String`
- default: `history` * default: `history`
```js ```js
window.$docsify = { window.$docsify = {
routerMode: 'history' // default: 'hash' routerMode: 'history' // default: 'hash'
} };
``` ```
## noCompileLinks ## noCompileLinks
- type: `Array` * type: `Array`
Sometimes we do not want docsify to handle our links. See [#203](https://github.com/QingWei-Li/docsify/issues/203) Sometimes we do not want docsify to handle our links. See [#203](https://github.com/QingWei-Li/docsify/issues/203)
```js ```js
window.$docsify = { window.$docsify = {
noCompileLinks: [ noCompileLinks: ['/foo', '/bar/.*']
'/foo', };
'/bar/.*'
]
}
``` ```
##

View file

@ -1,9 +1,8 @@
# Einstellungen # Einstellungen
**docsify** unterstützt zwei verschiedene Arten, um die Einstellungen anzupassen. Du kannst das `window.$docsify` anpassen, oder die Einstellungen über das script tag im `data-*` Attribut vornehmen. You can configure the `window.$docsify`.
```html ```html
<!-- über $docsify -->
<script> <script>
window.$docsify = { window.$docsify = {
repo: 'QingWei-Li/docsify', repo: 'QingWei-Li/docsify',
@ -11,37 +10,25 @@
coverpage: true coverpage: true
} }
</script> </script>
<!-- oder data-* -->
<script
src="//unpkg.com/docsify"
data-repo="QingWei-Li/docsify"
data-max-level="3"
data-coverpage>
</script>
``` ```
Beide Arten sind miteinander kompatibel, wobei die erste jedoch empfohlen wird. Sie ist deutlicher und kann in einer separaten Datei geführt werden.
!> Innerhalb des `window.$docsfiy` sollten die Optionen mit camelCase geschrieben werden.
## el ## el
- Typ: `String` * Typ: `String`
- Standard: `#app` * Standard: `#app`
Das DOM Element kann bei der Initialisierung gesetzt werden. Es kann ein CSS selector string oder ein richtiges HTMLElement sein. Das DOM Element kann bei der Initialisierung gesetzt werden. Es kann ein CSS selector string oder ein richtiges HTMLElement sein.
```js ```js
window.$docsify = { window.$docsify = {
el: '#app' el: '#app'
} };
``` ```
## repo ## repo
- Typ: `String` * Typ: `String`
- Standard: `null` * Standard: `null`
Verwende die repository URL oder eine Zeichenfolge aus `Benutzername/repo`, um das [GitHub Corner](http://tholman.com/github-corners/) widget in die obere rechte Ecke der Seite zu implementieren. Verwende die repository URL oder eine Zeichenfolge aus `Benutzername/repo`, um das [GitHub Corner](http://tholman.com/github-corners/) widget in die obere rechte Ecke der Seite zu implementieren.
@ -50,26 +37,26 @@ window.$docsify = {
repo: 'QingWei-Li/docsify', repo: 'QingWei-Li/docsify',
// oder // oder
repo: 'https://github.com/QingWei-Li/docsify/' repo: 'https://github.com/QingWei-Li/docsify/'
} };
``` ```
## max-level ## maxLevel
- Typ: `Number` * Typ: `Number`
- Standard: `6` * Standard: `6`
Maximale Anzahl der Inhaltsübersichtebenen. Maximale Anzahl der Inhaltsübersichtebenen.
```js ```js
window.$docsify = { window.$docsify = {
maxLevel: 4 maxLevel: 4
} };
``` ```
## load-navbar ## loadNavbar
- Typ: `Boolean|String` * Typ: `Boolean|String`
- Standard: `false` * Standard: `false`
Lädt die Navigationsleiste von der Markdown Datei `_navbar.md` falls **true**, oder vom gewählten Pfad. Lädt die Navigationsleiste von der Markdown Datei `_navbar.md` falls **true**, oder vom gewählten Pfad.
@ -80,13 +67,13 @@ window.$docsify = {
// lade von nav.md // lade von nav.md
loadNavbar: 'nav.md' loadNavbar: 'nav.md'
} };
``` ```
## load-sidebar ## loadSidebar
- Typ: `Boolean|String` * Typ: `Boolean|String`
- Standard: `false` * Standard: `false`
Lädt das seitliche Inhaltsverzeichnis von der Markdown Datei `_sidebar.md` falls **true**, oder vom gewählten Pfad. Lädt das seitliche Inhaltsverzeichnis von der Markdown Datei `_sidebar.md` falls **true**, oder vom gewählten Pfad.
@ -97,39 +84,39 @@ window.$docsify = {
// lade von summary.md // lade von summary.md
loadSidebar: 'summary.md' loadSidebar: 'summary.md'
} };
``` ```
## sub-max-level ## subMaxLevel
- Typ: `Number` * Typ: `Number`
- Standard: `0` * Standard: `0`
Wähle die maximale Anzahl der Unterpunkte pro Datei in der Inhaltsübersicht. Wähle die maximale Anzahl der Unterpunkte pro Datei in der Inhaltsübersicht.
```js ```js
window.$docsify = { window.$docsify = {
subMaxLevel: 2 subMaxLevel: 2
} };
``` ```
## auto2top ## auto2top
- Typ: `Boolean` * Typ: `Boolean`
- Standard: `false` * Standard: `false`
Scrolle zum Anfang der Seite, wenn die Route gewechselt wird. Scrolle zum Anfang der Seite, wenn die Route gewechselt wird.
```js ```js
window.$docsify = { window.$docsify = {
auto2top: true auto2top: true
} };
``` ```
## homepage ## homepage
- Typ: `String` * Typ: `String`
- Standard: `README.md` * Standard: `README.md`
`README.md` in deinem Ordner für die Dokumentation wird als Startseite für deine Webseite gesetzt, aber manchmal musst du das vielleicht ändern. `README.md` in deinem Ordner für die Dokumentation wird als Startseite für deine Webseite gesetzt, aber manchmal musst du das vielleicht ändern.
@ -139,13 +126,14 @@ window.$docsify = {
homepage: 'home.md', homepage: 'home.md',
// Oder verwende das README in deinem repo // Oder verwende das README in deinem repo
homepage: 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md' homepage:
} 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md'
};
``` ```
## base-path ## basePath
- Typ: `String` * Typ: `String`
Der Basispfad der Webseite. Du kannst einen anderen Ordner wählen, oder eine andere Domain. Der Basispfad der Webseite. Du kannst einen anderen Ordner wählen, oder eine andere Domain.
@ -157,14 +145,15 @@ window.$docsify = {
basePath: 'https://docsify.js.org/', basePath: 'https://docsify.js.org/',
// Oder lade Dateien von einem anderen repo // Oder lade Dateien von einem anderen repo
basePath: 'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/' basePath:
} 'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/'
};
``` ```
## coverpage ## coverpage
- Typ: `Boolean|String` * Typ: `Boolean|String`
- Standard: `false` * Standard: `false`
Aktiviere das [Titelseitenfeature](de-de/cover.md). Falls `true`, wird sie von `_coverpage.md` geladen. Aktiviere das [Titelseitenfeature](de-de/cover.md). Falls `true`, wird sie von `_coverpage.md` geladen.
@ -174,25 +163,25 @@ window.$docsify = {
// Anderer Dateiname // Anderer Dateiname
coverpage: 'cover.md' coverpage: 'cover.md'
} };
``` ```
## name ## name
- Typ: `String` * Typ: `String`
Webseitenname, wie er in der Inhaltsübersicht in der Seitenleiste angezeigt wird. Webseitenname, wie er in der Inhaltsübersicht in der Seitenleiste angezeigt wird.
```js ```js
window.$docsify = { window.$docsify = {
name: 'docsify' name: 'docsify'
} };
``` ```
## name-link ## nameLink
- Typ: `String` * Typ: `String`
- Standard: `window.location.pathname` * Standard: `window.location.pathname`
Der Name der Links. Der Name der Links.
@ -205,12 +194,12 @@ window.$docsify = {
'/zh-cn/': '/zh-cn/', '/zh-cn/': '/zh-cn/',
'/': '/' '/': '/'
} }
} };
``` ```
## markdown ## markdown
- Typ: `Function` * Typ: `Function`
Siehe [Markdown Konfiguration](de-de/markdown.md). Siehe [Markdown Konfiguration](de-de/markdown.md).
@ -229,26 +218,26 @@ window.$docsify = {
// Funktion // Funktion
markdown: function(marked, renderer) { markdown: function(marked, renderer) {
// ... // ...
return marked return marked;
}
} }
};
``` ```
## theme-color ## themeColor
- Typ: `String` * Typ: `String`
Passe die Farbe der Themen an. Verwende [CSS3 Variablen](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) und polyfill in älteren Browsern. Passe die Farbe der Themen an. Verwende [CSS3 Variablen](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) und polyfill in älteren Browsern.
```js ```js
window.$docsify = { window.$docsify = {
themeColor: '#3F51B5' themeColor: '#3F51B5'
} };
``` ```
## alias ## alias
- Typ: `Object` * Typ: `Object`
Verwende alternative Routen. Du kannst sie ungehindert anpassen. Supports RegExp. Verwende alternative Routen. Du kannst sie ungehindert anpassen. Supports RegExp.
@ -257,15 +246,16 @@ window.$docsify = {
alias: { alias: {
'/foo/(+*)': '/bar/$1', // supports regexp '/foo/(+*)': '/bar/$1', // supports regexp
'/zh-cn/changelog': '/changelog', '/zh-cn/changelog': '/changelog',
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG', '/changelog':
'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG',
'/.*/_sidebar.md': '/_sidebar.md' // See #301 '/.*/_sidebar.md': '/_sidebar.md' // See #301
} }
} };
``` ```
## auto-header ## autoHeader
- Typ: `Boolean` * Typ: `Boolean`
Sollten `loadSidebar` und `autoHeader` beide aktiviert sein, setze einen Header vor die Seite in jedem Link in `_sidebar.md`, bevor sie in HTML umgewandelt wird. Vergleiche [#78](https://github.com/QingWei-Li/docsify/issues/78). Sollten `loadSidebar` und `autoHeader` beide aktiviert sein, setze einen Header vor die Seite in jedem Link in `_sidebar.md`, bevor sie in HTML umgewandelt wird. Vergleiche [#78](https://github.com/QingWei-Li/docsify/issues/78).
@ -273,19 +263,19 @@ Sollten `loadSidebar` und `autoHeader` beide aktiviert sein, setze einen Header
window.$docsify = { window.$docsify = {
loadSidebar: true, loadSidebar: true,
autoHeader: true autoHeader: true
} };
``` ```
## execute-script ## executeScript
- Typ: `Boolean` * Typ: `Boolean`
Führe das Skript auf der Seite aus. Analysiere nur das erste script tag ([demo](de-de/themes.md)). Sollte Vue verwendet sein, wird es in der Standardeinstellung ausgeführt. Führe das Skript auf der Seite aus. Analysiere nur das erste script tag ([demo](de-de/themes.md)). Sollte Vue verwendet sein, wird es in der Standardeinstellung ausgeführt.
```js ```js
window.$docsify = { window.$docsify = {
executeScript: true executeScript: true
} };
``` ```
```markdown ```markdown
@ -298,29 +288,37 @@ window.$docsify = {
?> Nehme zur Kenntnis, dass, solltest du ein externes Skript ausführen, z.B. ein eingebettete jsfiddle demo, du sicher gehen solltest, das [external-script](de-de/plugins.md?id=external-script) plugin zu verwenden. ?> Nehme zur Kenntnis, dass, solltest du ein externes Skript ausführen, z.B. ein eingebettete jsfiddle demo, du sicher gehen solltest, das [external-script](de-de/plugins.md?id=external-script) plugin zu verwenden.
## no-emoji ## noEmoji
* type: `Boolean`
Verhindere die Umwandlung in Emojis: Verhindere die Umwandlung in Emojis:
```js ```js
window.$docsify = { window.$docsify = {
noEmoji: true noEmoji: true
} };
``` ```
## merge-navbar ## mergeNavbar
* type: `Boolean`
Navbar will be merged with the sidebar on smaller screens. Navbar will be merged with the sidebar on smaller screens.
```js ```js
window.$docsify = { window.$docsify = {
mergeNavbar: true mergeNavbar: true
} };
``` ```
## format-updated ## formatUpdated
* type: `String|Function`
We can display the file update date through **{docsify-updated<span>}</span>** variable. And format it by `formatUpdated`. We can display the file update date through **{docsify-updated<span>}</span>** variable. And format it by `formatUpdated`.
See https://github.com/lukeed/tinydate#patterns See https://github.com/lukeed/tinydate#patterns
```js ```js
window.$docsify = { window.$docsify = {
formatUpdated: '{MM}/{DD} {HH}:{mm}', formatUpdated: '{MM}/{DD} {HH}:{mm}',
@ -328,35 +326,43 @@ window.$docsify = {
formatUpdated: function(time) { formatUpdated: function(time) {
// ... // ...
return time return time;
}
} }
};
``` ```
## external-link-target ## externalLinkTarget
Currently it defaults to _blank, would be nice if configurable: * type: `String`
* default: `_blank`
Currently it defaults to \_blank, would be nice if configurable:
```js ```js
window.$docsify = { window.$docsify = {
externalLinkTarget: '_self' // default: '_blank' externalLinkTarget: '_self' // default: '_blank'
} };
``` ```
## routerMode
## noCompileLinks * type: `String`
* default: `history`
- type: `Array`
Sometimes we do not want docsify to handle our links. See [#203](https://github.com/QingWei-Li/docsify/issues/203)
```js ```js
window.$docsify = { window.$docsify = {
noCompileLinks: [ routerMode: 'history' // default: 'hash'
'/foo', };
'/bar/.*' ```
]
} ## noCompileLinks
* 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 = {
noCompileLinks: ['/foo', '/bar/.*']
};
``` ```

View file

@ -1,9 +1,8 @@
# 配置项 # 配置项
docsify 有两种配置参数的方式。一种是配置在 `window.$docsify` 里,另一种是给 `script` 标签添加 `data-*` 属性。 你可以配置在 `window.$docsify` 里。
```html ```html
<!-- 方法 1 -->
<script> <script>
window.$docsify = { window.$docsify = {
repo: 'QingWei-Li/docsify', repo: 'QingWei-Li/docsify',
@ -11,38 +10,25 @@ docsify 有两种配置参数的方式。一种是配置在 `window.$docsify`
coverpage: true coverpage: true
} }
</script> </script>
<!-- 方法 2 -->
<script
src="//unpkg.com/docsify"
data-repo="QingWei-Li/docsify"
data-max-level="3"
data-coverpage>
</script>
``` ```
两种方式可以共存,推荐第一种做法——直接配置 `window.$docsify` 对象——这会让你的配置更加清晰,同时也可以方便的将配置单独写到另一个文件里。
!> 通过 `window.$docsify` 配置属性,需要将属性改成驼峰命名法。通过 `data-*` 属性配置,保持短横线的命名规则。
## el ## el
- 类型:`String` * 类型:`String`
- 默认值:`#app` * 默认值:`#app`
docsify 初始化的挂载元素,可以是一个 CSS 选择器,默认为 `#app` 如果不存在就直接绑定在 `body` 上。 docsify 初始化的挂载元素,可以是一个 CSS 选择器,默认为 `#app` 如果不存在就直接绑定在 `body` 上。
```js ```js
window.$docsify = { window.$docsify = {
el: '#app' el: '#app'
} };
``` ```
## repo ## repo
- 类型:`String` * 类型:`String`
- 默认值: `null` * 默认值: `null`
配置仓库地址或者 `username/repo` 的字符串,会在页面右上角渲染一个 [GitHub Corner](http://tholman.com/github-corners/) 挂件。 配置仓库地址或者 `username/repo` 的字符串,会在页面右上角渲染一个 [GitHub Corner](http://tholman.com/github-corners/) 挂件。
@ -51,28 +37,39 @@ window.$docsify = {
repo: 'QingWei-Li/docsify', repo: 'QingWei-Li/docsify',
// or // or
repo: 'https://github.com/QingWei-Li/docsify/' repo: 'https://github.com/QingWei-Li/docsify/'
} };
``` ```
## max-level ## max-level
- 类型:`Number` * 类型:`Number`
- 默认值: `6` * 默认值: `6`
默认情况下会抓取文档中所有标题渲染成目录,可配置最大支持渲染的标题层级。 默认情况下会抓取文档中所有标题渲染成目录,可配置最大支持渲染的标题层级。
```js ```js
window.$docsify = { window.$docsify = {
maxLevel: 4 maxLevel: 4
} };
``` ```
## load-navbar ## maxLevel
- 类型:`Boolean|String` * Type: `Number`
- 默认值: `false` * Default: `6`
Maximum Table of content level.
```js
window.$docsify = {
maxLevel: 4
};
```
## loadNavbar
* 类型:`Boolean|String`
* 默认值: `false`
加载自定义导航栏,参考[定制导航栏](zh-cn/custom-navbar.md) 了解用法。设置为 `true` 后会加载 `_navbar.md` 文件,也可以自定义加载的文件名。 加载自定义导航栏,参考[定制导航栏](zh-cn/custom-navbar.md) 了解用法。设置为 `true` 后会加载 `_navbar.md` 文件,也可以自定义加载的文件名。
@ -83,13 +80,13 @@ window.$docsify = {
// 加载 nav.md // 加载 nav.md
loadNavbar: 'nav.md' loadNavbar: 'nav.md'
} };
``` ```
## load-sidebar ## loadSidebar
- 类型:`Boolean|String` * 类型:`Boolean|String`
- 默认值: `false` * 默认值: `false`
加载自定义侧边栏,参考[多页文档](zh-cn/more-pages.md)。设置为 `true` 后会加载 `_sidebar.md` 文件,也可以自定义加载的文件名。 加载自定义侧边栏,参考[多页文档](zh-cn/more-pages.md)。设置为 `true` 后会加载 `_sidebar.md` 文件,也可以自定义加载的文件名。
@ -100,42 +97,39 @@ window.$docsify = {
// 加载 summary.md // 加载 summary.md
loadSidebar: 'summary.md' loadSidebar: 'summary.md'
} };
``` ```
## sub-max-level ## subMaxLevel
- 类型:`Number` * 类型:`Number`
- 默认值: `0` * 默认值: `0`
自定义侧边栏后默认不会再生成目录,你也可以通过设置生成目录的最大层级开启这个功能。 自定义侧边栏后默认不会再生成目录,你也可以通过设置生成目录的最大层级开启这个功能。
```js ```js
window.$docsify = { window.$docsify = {
subMaxLevel: 2 subMaxLevel: 2
} };
``` ```
## auto2top ## auto2top
- 类型:`Boolean` * 类型:`Boolean`
- 默认值: `false` * 默认值: `false`
切换页面后是否自动跳转到页面顶部。 切换页面后是否自动跳转到页面顶部。
```js ```js
window.$docsify = { window.$docsify = {
auto2top: true auto2top: true
} };
``` ```
## homepage ## homepage
- 类型:`String` * 类型:`String`
- 默认值: `README.md` * 默认值: `README.md`
设置首页文件加载路径。适合不想将 `README.md` 作为入口文件渲染,或者是文档存放在其他位置的情况使用。 设置首页文件加载路径。适合不想将 `README.md` 作为入口文件渲染,或者是文档存放在其他位置的情况使用。
@ -145,13 +139,14 @@ window.$docsify = {
homepage: 'home.md', homepage: 'home.md',
// 文档和仓库根目录下的 README.md 内容一致 // 文档和仓库根目录下的 README.md 内容一致
homepage: 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md' homepage:
} 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md'
};
``` ```
## base-path ## basePath
- 类型:`String` * 类型:`String`
文档加载的根路径,可以是二级路径或者是其他域名的路径。 文档加载的根路径,可以是二级路径或者是其他域名的路径。
@ -163,15 +158,15 @@ window.$docsify = {
basePath: 'https://docsify.js.org/', basePath: 'https://docsify.js.org/',
// 甚至直接渲染其他仓库 readme // 甚至直接渲染其他仓库 readme
basePath: 'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/' basePath:
} 'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/'
};
``` ```
## coverpage ## coverpage
- 类型:`Boolean|String` * 类型:`Boolean|String`
- 默认值: `false` * 默认值: `false`
启用[封面页](zh-cn/cover.md)。开启后是加载 `_coverpage.md` 文件,也可以自定义文件名。 启用[封面页](zh-cn/cover.md)。开启后是加载 `_coverpage.md` 文件,也可以自定义文件名。
@ -181,26 +176,25 @@ window.$docsify = {
// 自定义文件名 // 自定义文件名
coverpage: 'cover.md' coverpage: 'cover.md'
} };
``` ```
## name ## name
- 类型:`String` * 类型:`String`
文档标题,会显示在侧边栏顶部。 文档标题,会显示在侧边栏顶部。
```js ```js
window.$docsify = { window.$docsify = {
name: 'docsify' name: 'docsify'
} };
``` ```
## name-link ## nameLink
- 类型:`String` * 类型:`String`
- 默认值:`window.location.pathname` * 默认值:`window.location.pathname`
点击文档标题后跳转的链接地址。 点击文档标题后跳转的链接地址。
@ -213,12 +207,12 @@ window.$docsify = {
'/zh-cn/': '/zh-cn/', '/zh-cn/': '/zh-cn/',
'/': '/' '/': '/'
} }
} };
``` ```
## markdown ## markdown
- 类型: `Object|Function` * 类型: `Object|Function`
参考 [Markdown 配置](zh-cn/markdown.md)。 参考 [Markdown 配置](zh-cn/markdown.md)。
@ -237,44 +231,44 @@ window.$docsify = {
// function // function
markdown: function(marked, renderer) { markdown: function(marked, renderer) {
// ... // ...
return marked return marked;
}
} }
};
``` ```
## theme-color ## themeColor
- 类型:`String` * 类型:`String`
替换主题色。利用 [CSS3 支持变量](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables)的特性,对于老的浏览器有 polyfill 处理。 替换主题色。利用 [CSS3 支持变量](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables)的特性,对于老的浏览器有 polyfill 处理。
```js ```js
window.$docsify = { window.$docsify = {
themeColor: '#3F51B5' themeColor: '#3F51B5'
} };
``` ```
## alias ## alias
- 类型:`Object` * 类型:`Object`
定义路由别名,可以更自由的定义路由规则。 支持正则。 定义路由别名,可以更自由的定义路由规则。 支持正则。
```js ```js
window.$docsify = { window.$docsify = {
alias: { alias: {
'/foo/(+*)': '/bar/$1', // supports regexp '/foo/(+*)': '/bar/$1', // supports regexp
'/zh-cn/changelog': '/changelog', '/zh-cn/changelog': '/changelog',
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG', '/changelog':
'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG',
'/.*/_sidebar.md': '/_sidebar.md' // See #301 '/.*/_sidebar.md': '/_sidebar.md' // See #301
} }
} };
``` ```
## auto-header ## autoHeader
- 类型:`Boolean` * 类型:`Boolean`
同时设置 `loadSidebar` 和 `autoHeader` 后,可以根据 `_sidebar.md` 的内容自动为每个页面增加标题。[#78](https://github.com/QingWei-Li/docsify/issues/78) 同时设置 `loadSidebar` 和 `autoHeader` 后,可以根据 `_sidebar.md` 的内容自动为每个页面增加标题。[#78](https://github.com/QingWei-Li/docsify/issues/78)
@ -282,19 +276,19 @@ window.$docsify = {
window.$docsify = { window.$docsify = {
loadSidebar: true, loadSidebar: true,
autoHeader: true autoHeader: true
} };
``` ```
## execute-script ## executeScript
- 类型:`Boolean` * 类型:`Boolean`
执行文档里的 script 标签里的脚本,只执行第一个 script ([demo](zh-cn/themes.md))。 如果 Vue 存在,则自动开启。 执行文档里的 script 标签里的脚本,只执行第一个 script ([demo](zh-cn/themes.md))。 如果 Vue 存在,则自动开启。
```js ```js
window.$docsify = { window.$docsify = {
executeScript: true executeScript: true
} };
``` ```
```markdown ```markdown
@ -303,35 +297,40 @@ window.$docsify = {
<script> <script>
console.log(2333) console.log(2333)
</script> </script>
``` ```
注意如果执行的是一个外链脚本,比如 jsfiddle 的内嵌 demo,请确保引入 [external-script](plugins.md?id=外链脚本-external-script) 插件。 注意如果执行的是一个外链脚本,比如 jsfiddle 的内嵌 demo,请确保引入 [external-script](plugins.md?id=外链脚本-external-script) 插件。
## no-emoji ## noEmoji
* type: `Boolean`
禁用 emoji 解析。 禁用 emoji 解析。
```js ```js
window.$docsify = { window.$docsify = {
noEmoji: true noEmoji: true
} };
``` ```
## merge-navbar ## mergeNavbar
* type: `Boolean`
小屏设备下合并导航栏到侧边栏。 小屏设备下合并导航栏到侧边栏。
```js ```js
window.$docsify = { window.$docsify = {
mergeNavbar: true mergeNavbar: true
} };
``` ```
## format-updated ## formatUpdated
* type: `String|Function`
我们可以显示文档更新日期通过 **{docsify-updated<span>}</span>** 变量. 并且格式化日期通过 `formatUpdated`。参考 https://github.com/lukeed/tinydate#patterns
我们可以显示文档更新日期通过 **{docsify-updated<span>}</span>** 变量. 并且格式化日期通过 `formatUpdated`。
参考 https://github.com/lukeed/tinydate#patterns
```js ```js
window.$docsify = { window.$docsify = {
formatUpdated: '{MM}/{DD} {HH}:{mm}', formatUpdated: '{MM}/{DD} {HH}:{mm}',
@ -339,35 +338,43 @@ window.$docsify = {
formatUpdated: function(time) { formatUpdated: function(time) {
// ... // ...
return time return time;
}
} }
};
``` ```
## external-link-target ## externalLinkTarget
当前默认为 _blank, 配置一下就可以: * type: `String`
* default: `_blank`
当前默认为 \_blank, 配置一下就可以:
```js ```js
window.$docsify = { window.$docsify = {
externalLinkTarget: '_self' // default: '_blank' externalLinkTarget: '_self' // default: '_blank'
} };
``` ```
## routerMode
## noCompileLinks * type: `String`
* default: `history`
- 类型: `Array`
有时我们不希望 docsify 处理我们的链接。 参考 [#203](https://github.com/QingWei-Li/docsify/issues/203)
```js ```js
window.$docsify = { window.$docsify = {
noCompileLinks: [ routerMode: 'history' // default: 'hash'
'/foo', };
'/bar/.*' ```
]
} ## noCompileLinks
* 类型: `Array`
有时我们不希望 docsify 处理我们的链接。 参考 [#203](https://github.com/QingWei-Li/docsify/issues/203)
```js
window.$docsify = {
noCompileLinks: ['/foo', '/bar/.*']
};
``` ```