mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-09 13:26:34 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b85eb0ff4b | ||
|
|
efa8d25912 | ||
|
|
437737cc5a | ||
|
|
992ff77808 | ||
|
|
4cf13db685 | ||
|
|
e54062f80d | ||
|
|
cee8ac6698 | ||
|
|
d057f66fce | ||
|
|
9b0f1978a4 | ||
|
|
d9848c3384 | ||
|
|
4dabae3bf2 | ||
|
|
b430993f4f | ||
|
|
2e00f4c993 | ||
|
|
7fb5ce6c84 | ||
|
|
c4aa22c56d | ||
|
|
9af855921e | ||
|
|
4492c3e19f | ||
|
|
f598e53098 | ||
|
|
4bde6d685c | ||
|
|
ce0e9acd50 | ||
|
|
e8117e515d | ||
|
|
25e09dfe07 | ||
|
|
a6b46a3e26 | ||
|
|
d469442eae | ||
|
|
9f310bbd7d | ||
|
|
cc8a7c97b6 | ||
|
|
19da658ba2 | ||
|
|
97db30a0b9 | ||
|
|
3a0765e11e | ||
|
|
aaf71b1ac0 | ||
|
|
b37781e949 | ||
|
|
54a48dd3ff | ||
|
|
1aabc41db7 | ||
|
|
d087d5753b | ||
|
|
bb793ec08e |
+875
-112
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,7 @@
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/QingWei-Li/docsify"><img alt="Travis Status" src="https://img.shields.io/travis/QingWei-Li/docsify/master.svg?style=flat-square"></a>
|
||||
<a href="https://www.npmjs.com/package/docsify"><img alt="npm" src="https://img.shields.io/npm/v/docsify.svg?style=flat-square"></a>
|
||||
<a href="https://cdnjs.com/libraries/docsify"><img alt="cdnjs" src="https://img.shields.io/cdnjs/v/docsify.svg?style=flat-square"></a>
|
||||
<a href="https://github.com/QingWei-Li/donate"><img alt="donate" src="https://img.shields.io/badge/%24-donate-ff69b4.svg?style=flat-square"></a>
|
||||
<a href="https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FQingWei-Li%2Fdocsify?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FQingWei-Li%2Fdocsify.svg?type=shield"/></a>
|
||||
</p>
|
||||
@@ -23,7 +24,7 @@
|
||||
## Features
|
||||
|
||||
- No statically built html files
|
||||
- Simple and lightweight (~16kB gzipped)
|
||||
- Simple and lightweight (~18kB gzipped)
|
||||
- Smart full-text search plugin
|
||||
- Multiple themes
|
||||
- Useful plugin API
|
||||
@@ -69,6 +70,9 @@ These projects are using docsify to generate their sites. Pull requests welcome
|
||||
| [JS MythBusters](https://mythbusters.js.org) | An optimization handbook from a high level point of view. |
|
||||
| [hire-me](https://fvcproductions.github.io/hire-me) | A path to getting an awesome tech gig. |
|
||||
| [vue-amap](https://elemefe.github.io/vue-amap/) | A Map Component Library Base on Vue 2.x and Gaode Map. |
|
||||
| [samlify](https://samlify.js.org) | Node.js SAML2 library |
|
||||
| [palettify](https://dobromir-hristov.github.io/palettify/) | A color palette effects assistant |
|
||||
| [commitlint](https://marionebl.github.io/commitlint/) | Lint commit messages |
|
||||
|
||||
## Similar projects
|
||||
|
||||
@@ -89,7 +93,7 @@ These projects are using docsify to generate their sites. Pull requests welcome
|
||||
## Development
|
||||
|
||||
```bash
|
||||
npm i && npm run dev
|
||||
npm run bootstrap && npm run dev
|
||||
open http://localhost:3000
|
||||
```
|
||||
|
||||
|
||||
+7
-10
@@ -28,7 +28,6 @@ var build = function (opts) {
|
||||
console.log(dest)
|
||||
bundle.write({
|
||||
format: 'iife',
|
||||
moduleName: opts.moduleName || 'D',
|
||||
dest: dest
|
||||
})
|
||||
})
|
||||
@@ -43,19 +42,18 @@ build({
|
||||
})
|
||||
|
||||
var plugins = [
|
||||
{ name: 'search', entry: 'search/index.js', moduleName: 'Search' },
|
||||
{ name: 'ga', entry: 'ga.js', moduleName: 'GA' },
|
||||
{ name: 'emoji', entry: 'emoji.js', moduleName: 'Emoji' },
|
||||
{ name: 'external-script', entry: 'external-script.js', moduleName: 'ExternalScript' },
|
||||
{ name: 'front-matter', entry: 'front-matter/index.js', moduleName: 'FrontMatter' },
|
||||
{ name: 'zoom-image', entry: 'zoom-image.js', moduleName: 'ZoomImage' }
|
||||
{ name: 'search', entry: 'search/index.js' },
|
||||
{ name: 'ga', entry: 'ga.js' },
|
||||
{ name: 'emoji', entry: 'emoji.js' },
|
||||
{ name: 'external-script', entry: 'external-script.js' },
|
||||
{ name: 'front-matter', entry: 'front-matter/index.js' },
|
||||
{ name: 'zoom-image', entry: 'zoom-image.js' }
|
||||
]
|
||||
|
||||
plugins.forEach(item => {
|
||||
build({
|
||||
entry: 'plugins/' + item.entry,
|
||||
output: 'plugins/' + item.name + '.js',
|
||||
moduleName: 'D.' + item.moduleName
|
||||
output: 'plugins/' + item.name + '.js'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -69,7 +67,6 @@ if (isProd) {
|
||||
build({
|
||||
entry: 'plugins/' + item.entry,
|
||||
output: 'plugins/' + item.name + '.min.js',
|
||||
moduleName: 'D.' + item.moduleName,
|
||||
plugins: [uglify()]
|
||||
})
|
||||
})
|
||||
|
||||
@@ -32,6 +32,12 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
git commit -m "[build] $VERSION $RELEASE_TAG"
|
||||
npm version $VERSION --message "[release] $VERSION $RELEASE_TAG"
|
||||
|
||||
# changelog
|
||||
node_modules/.bin/standard-changelog --first-release
|
||||
|
||||
git add .
|
||||
git commit -m "chore: add changelog $VERSION"
|
||||
|
||||
# publish
|
||||
git push origin refs/tags/v$VERSION
|
||||
git push
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
<script>
|
||||
window.$docsify = {
|
||||
alias: {
|
||||
'/de-de/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',
|
||||
'/.*/_navbar.md': '/_navbar.md'
|
||||
},
|
||||
auto2top: true,
|
||||
basePath: '/docs/',
|
||||
@@ -30,14 +29,13 @@
|
||||
loadSidebar: true,
|
||||
coverpage: true,
|
||||
name: 'docsify',
|
||||
subMaxLevel: 2,
|
||||
subMaxLevel: 0,
|
||||
mergeNavbar: true,
|
||||
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||
routerMode: 'history',
|
||||
plugins: [
|
||||
function(hook, vm) {
|
||||
hook.beforeEach(function (html) {
|
||||
var url = 'https://github.com/QingWei-Li/docsify/blob/master' + vm.router.getFile()
|
||||
var url = 'https://github.com/QingWei-Li/docsify/blob/master/' + vm.route.file
|
||||
var editHtml = '[:memo: Edit Document](' + url + ')\n'
|
||||
|
||||
return editHtml
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ See the [Quick start](quickstart.md) for more details.
|
||||
## Features
|
||||
|
||||
* No statically built html files
|
||||
* Simple and lightweight (~16kB gzipped)
|
||||
* Simple and lightweight (~18kB gzipped)
|
||||
* Smart full-text search plugin
|
||||
* Multiple themes
|
||||
* Useful plugin API
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||

|
||||
|
||||
# docsify <small>4.1.11</small>
|
||||
# docsify <small>4.2.1</small>
|
||||
|
||||
> A magical documentation site generator.
|
||||
|
||||
- Simple and lightweight (~16kB gzipped)
|
||||
- Simple and lightweight (~18kB gzipped)
|
||||
- No statically built html files
|
||||
- Multiple themes
|
||||
|
||||
|
||||
+35
-2
@@ -250,11 +250,12 @@ window.$docsify = {
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
Set the route alias. You can freely manage routing rules.
|
||||
Set the route alias. You can freely manage routing rules. Supports RegExp.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
alias: {
|
||||
'/foo/(+*)': '/bar/$1', // supports regexp
|
||||
'/zh-cn/changelog': '/changelog',
|
||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||
}
|
||||
@@ -298,6 +299,8 @@ Note that if you are running an external script, e.g. an embedded jsfiddle demo,
|
||||
|
||||
## no-emoji
|
||||
|
||||
- type: `Boolean`
|
||||
|
||||
Disabled emoji parse.
|
||||
|
||||
```js
|
||||
@@ -308,6 +311,8 @@ window.$docsify = {
|
||||
|
||||
## merge-navbar
|
||||
|
||||
- type: `Boolean`
|
||||
|
||||
Navbar will be merged with the sidebar on smaller screens.
|
||||
|
||||
```js
|
||||
@@ -317,6 +322,9 @@ window.$docsify = {
|
||||
```
|
||||
|
||||
## format-updated
|
||||
|
||||
- type: `String|Function`
|
||||
|
||||
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
|
||||
```js
|
||||
@@ -333,7 +341,10 @@ window.$docsify = {
|
||||
|
||||
## external-link-target
|
||||
|
||||
Currently it defaults to _blank, would be nice if configurable:
|
||||
- type: `String`
|
||||
- default: `_self`
|
||||
|
||||
Target to open external links. Default `'_blank'` (new window/tab)
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -342,8 +353,30 @@ window.$docsify = {
|
||||
```
|
||||
|
||||
## router-mode
|
||||
|
||||
- type: `String`
|
||||
- default: `history`
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
routerMode: 'history' // default: 'hash'
|
||||
}
|
||||
```
|
||||
|
||||
## 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/.*'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ Set `coverpage` to **true**, and create a `_coverpage.md`:
|
||||
|
||||
> A magical documentation site generator.
|
||||
|
||||
- Simple and lightweight (~16kB gzipped)
|
||||
- Simple and lightweight (~18kB gzipped)
|
||||
- No statically built html files
|
||||
- Multiple themes
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Siehe [Schnellstart](de-de/quickstart.md) für weitere Informationen.
|
||||
## Features
|
||||
|
||||
* keine generierten, statischen HTML Dateien
|
||||
* einfach und klein (~16kB gzipped)
|
||||
* einfach und klein (~18kB gzipped)
|
||||
* smarte Erweiterung mit Volltextsuche
|
||||
* mehrere Themes
|
||||
* praktische API für Erweiterungen
|
||||
|
||||
@@ -250,11 +250,12 @@ window.$docsify = {
|
||||
|
||||
- Typ: `Object`
|
||||
|
||||
Verwende alternative Routen. Du kannst sie ungehindert anpassen.
|
||||
Verwende alternative Routen. Du kannst sie ungehindert anpassen. Supports RegExp.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
alias: {
|
||||
'/foo/(+*)': '/bar/$1', // supports regexp
|
||||
'/zh-cn/changelog': '/changelog',
|
||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||
}
|
||||
@@ -317,7 +318,7 @@ window.$docsify = {
|
||||
```
|
||||
|
||||
## format-updated
|
||||
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
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -340,3 +341,21 @@ window.$docsify = {
|
||||
externalLinkTarget: '_self' // default: '_blank'
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 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/.*'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ Setze `coverpage` auf **true**, und erstelle `_coverpage.md`:
|
||||
|
||||
> Ein magischer Generator für Dokumentationsseiten.
|
||||
|
||||
- Einfach und wenig Speicherbedarf (~16kB gzipped)
|
||||
- Einfach und wenig Speicherbedarf (~18kB gzipped)
|
||||
- Keine statischen HTML Dateien
|
||||
- Mehrere Themes
|
||||
|
||||
|
||||
@@ -25,3 +25,27 @@ Generelle Tipps wie:
|
||||
wird wie folgt gerendert:
|
||||
|
||||
?> *TODO* unit test
|
||||
|
||||
## Ignore to compile link
|
||||
|
||||
Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example
|
||||
|
||||
```md
|
||||
[link](/demo/)
|
||||
```
|
||||
|
||||
|
||||
It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.
|
||||
|
||||
Now you can do that
|
||||
|
||||
```md
|
||||
[link](/demo/ ":ignore")
|
||||
```
|
||||
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.
|
||||
|
||||
```md
|
||||
[link](/demo/ ":ignore title")
|
||||
|
||||
<a href="/demo/" title="title">link</a>
|
||||
```
|
||||
|
||||
@@ -25,3 +25,28 @@ General tips like:
|
||||
are rendered as:
|
||||
|
||||
?> *TODO* unit test
|
||||
|
||||
## Ignore to compile link
|
||||
|
||||
Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example
|
||||
|
||||
```md
|
||||
[link](/demo/)
|
||||
```
|
||||
|
||||
|
||||
It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.
|
||||
|
||||
Now you can do that
|
||||
|
||||
```md
|
||||
[link](/demo/ ":ignore")
|
||||
```
|
||||
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.
|
||||
|
||||
```md
|
||||
[link](/demo/ ":ignore title")
|
||||
|
||||
<a href="/demo/" title="title">link</a>
|
||||
```
|
||||
|
||||
|
||||
+3
-4
@@ -23,9 +23,8 @@
|
||||
<script>
|
||||
window.$docsify = {
|
||||
alias: {
|
||||
'/de-de/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',
|
||||
'/.*/_navbar.md': '/_navbar.md'
|
||||
},
|
||||
auto2top: true,
|
||||
coverpage: true,
|
||||
@@ -53,7 +52,7 @@
|
||||
plugins: [
|
||||
function(hook, vm) {
|
||||
hook.beforeEach(function (html) {
|
||||
var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs' + vm.route.file
|
||||
var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs/' + vm.route.file
|
||||
var editHtml = '[:memo: Edit Document](' + url + ')\n'
|
||||
|
||||
return editHtml
|
||||
|
||||
@@ -12,7 +12,7 @@ docsify 是一个动态生成文档网站的工具。不同于 GitBook、Hexo
|
||||
|
||||
## 特性
|
||||
- 无需构建,写完文档直接发布
|
||||
- 容易使用并且轻量 (~16kB gzipped)
|
||||
- 容易使用并且轻量 (~18kB gzipped)
|
||||
- 智能的全文搜索
|
||||
- 提供多套主题
|
||||
- 丰富的 API
|
||||
|
||||
@@ -258,12 +258,13 @@ window.$docsify = {
|
||||
|
||||
- 类型:`Object`
|
||||
|
||||
定义路由别名,可以更自由的定义路由规则。
|
||||
定义路由别名,可以更自由的定义路由规则。 支持正则。
|
||||
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
alias: {
|
||||
'/foo/(+*)': '/bar/$1', // supports regexp
|
||||
'/zh-cn/changelog': '/changelog',
|
||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||
}
|
||||
@@ -327,7 +328,8 @@ window.$docsify = {
|
||||
```
|
||||
|
||||
## format-updated
|
||||
我们可以显示文档更新日期通过 **{docsify-updated<span>}</span>** 变量. 并且格式化日期通过 `formatUpdated`.
|
||||
|
||||
我们可以显示文档更新日期通过 **{docsify-updated<span>}</span>** 变量. 并且格式化日期通过 `formatUpdated`.
|
||||
参考 https://github.com/lukeed/tinydate#patterns
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -350,3 +352,21 @@ window.$docsify = {
|
||||
externalLinkTarget: '_self' // default: '_blank'
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 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/.*'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -24,3 +24,28 @@ docsify 扩展了一些 Markdown 语法,可以让文档更易读。
|
||||
|
||||
?> *TODO* 完善示例
|
||||
|
||||
|
||||
## Ignore to compile link
|
||||
|
||||
Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example
|
||||
|
||||
```md
|
||||
[link](/demo/)
|
||||
```
|
||||
|
||||
|
||||
It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.
|
||||
|
||||
Now you can do that
|
||||
|
||||
```md
|
||||
[link](/demo/ ":ignore")
|
||||
```
|
||||
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.
|
||||
|
||||
```md
|
||||
[link](/demo/ ":ignore title")
|
||||
|
||||
<a href="/demo/" title="title">link</a>
|
||||
```
|
||||
|
||||
|
||||
+69
-19
@@ -80,7 +80,8 @@ var config = merge({
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerModel: 'hash'
|
||||
routerModel: 'hash',
|
||||
noCompileLinks: []
|
||||
}, window.$docsify);
|
||||
|
||||
var script = document.currentScript ||
|
||||
@@ -2717,8 +2718,9 @@ function parseQuery (query) {
|
||||
query.split('&').forEach(function (param) {
|
||||
var parts = param.replace(/\+/g, ' ').split('=');
|
||||
|
||||
res[parts[0]] = decode(parts[1]);
|
||||
res[parts[0]] = parts[1] && decode(parts[1]);
|
||||
});
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -2726,7 +2728,9 @@ function stringifyQuery (obj) {
|
||||
var qs = [];
|
||||
|
||||
for (var key in obj) {
|
||||
qs.push(((encode(key)) + "=" + (encode(obj[key]))).toLowerCase());
|
||||
qs.push(obj[key]
|
||||
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
|
||||
: encode(key));
|
||||
}
|
||||
|
||||
return qs.length ? ("?" + (qs.join('&'))) : ''
|
||||
@@ -2757,6 +2761,8 @@ var cleanPath = cached(function (path) {
|
||||
.replace(/([^:])\/{2,}/g, '$1/')
|
||||
});
|
||||
|
||||
var cachedLinks = {};
|
||||
|
||||
var Compiler = function Compiler (config, router) {
|
||||
this.config = config;
|
||||
this.router = router;
|
||||
@@ -2791,6 +2797,19 @@ var Compiler = function Compiler (config, router) {
|
||||
});
|
||||
};
|
||||
|
||||
Compiler.prototype.matchNotCompileLink = function matchNotCompileLink (link) {
|
||||
var links = this.config.noCompileLinks;
|
||||
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
var n = links[i];
|
||||
var re = cachedLinks[n] || (cachedLinks[n] = new RegExp(("^" + n + "$")));
|
||||
|
||||
if (re.test(link)) {
|
||||
return link
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Compiler.prototype._initRenderer = function _initRenderer () {
|
||||
var renderer = new marked.Renderer();
|
||||
var ref = this;
|
||||
@@ -2834,11 +2853,16 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||
};
|
||||
renderer.link = function (href, title, text) {
|
||||
var blank = '';
|
||||
if (!/:|(\/{2})/.test(href)) {
|
||||
|
||||
if (!/:|(\/{2})/.test(href) &&
|
||||
!_self.matchNotCompileLink(href) &&
|
||||
!/(\s?:ignore)(\s\S+)?$/.test(title)) {
|
||||
href = router.toURL(href, null, router.getCurrentPath());
|
||||
} else {
|
||||
blank = " target=\"" + linkTarget + "\"";
|
||||
title = title && title.replace(/:ignore/g, '').trim();
|
||||
}
|
||||
|
||||
if (title) {
|
||||
title = " title=\"" + title + "\"";
|
||||
}
|
||||
@@ -3162,7 +3186,7 @@ function renderMixin (proto) {
|
||||
this._renderTo('.sidebar-nav', this.compiler.sidebar(text, maxLevel));
|
||||
var activeEl = getAndActive(this.router, '.sidebar-nav', true, true);
|
||||
if (loadSidebar && activeEl) {
|
||||
activeEl.parentNode.innerHTML += this.compiler.subSidebar(subMaxLevel);
|
||||
activeEl.parentNode.innerHTML += (this.compiler.subSidebar(subMaxLevel) || '');
|
||||
} else {
|
||||
// reset toc
|
||||
this.compiler.subSidebar();
|
||||
@@ -3200,6 +3224,10 @@ function renderMixin (proto) {
|
||||
var this$1 = this;
|
||||
if ( opt === void 0 ) opt = {};
|
||||
|
||||
if (!text) {
|
||||
return renderMain.call(this, text)
|
||||
}
|
||||
|
||||
callHook(this, 'beforeEach', text, function (result) {
|
||||
var html = this$1.isHTML ? result : this$1.compiler.compile(result);
|
||||
if (opt.updatedAt) {
|
||||
@@ -3298,8 +3326,15 @@ function initRender (vm) {
|
||||
toggleClass(body, 'ready');
|
||||
}
|
||||
|
||||
function getAlias (path, alias) {
|
||||
return alias[path] ? getAlias(alias[path], alias) : path
|
||||
var cached$1 = {};
|
||||
|
||||
function getAlias (path, alias, last) {
|
||||
var match = Object.keys(alias).filter(function (key) {
|
||||
var re = cached$1[key] || (cached$1[key] = new RegExp(("^" + key + "$")));
|
||||
return re.test(path) && path !== last
|
||||
})[0];
|
||||
|
||||
return match ? getAlias(path.replace(cached$1[match], alias[match]), alias, path) : path
|
||||
}
|
||||
|
||||
function getFileName (path) {
|
||||
@@ -3318,7 +3353,7 @@ History.prototype.getBasePath = function getBasePath () {
|
||||
return this.config.basePath
|
||||
};
|
||||
|
||||
History.prototype.getFile = function getFile (path) {
|
||||
History.prototype.getFile = function getFile (path, isRelative) {
|
||||
path = path || this.getCurrentPath();
|
||||
|
||||
var ref = this;
|
||||
@@ -3330,6 +3365,10 @@ History.prototype.getFile = function getFile (path) {
|
||||
path = path === '/README.md' ? (config.homepage || path) : path;
|
||||
path = isAbsolutePath(path) ? path : getPath(base, path);
|
||||
|
||||
if (isRelative) {
|
||||
path = path.replace(new RegExp(("^" + base)), '');
|
||||
}
|
||||
|
||||
return path
|
||||
};
|
||||
|
||||
@@ -3423,7 +3462,7 @@ var HashHistory = (function (History$$1) {
|
||||
|
||||
return {
|
||||
path: path,
|
||||
file: this.getFile(path),
|
||||
file: this.getFile(path, true),
|
||||
query: parseQuery(query)
|
||||
}
|
||||
};
|
||||
@@ -3536,6 +3575,12 @@ function routerMixin (proto) {
|
||||
|
||||
var lastRoute = {};
|
||||
|
||||
function updateRender (vm) {
|
||||
vm.router.normalize();
|
||||
vm.route = vm.router.parse();
|
||||
body.setAttribute('data-page', vm.route.file);
|
||||
}
|
||||
|
||||
function initRouter (vm) {
|
||||
var config = vm.config;
|
||||
var mode = config.routerMode || 'hash';
|
||||
@@ -3548,13 +3593,11 @@ function initRouter (vm) {
|
||||
}
|
||||
|
||||
vm.router = router;
|
||||
|
||||
router.normalize();
|
||||
lastRoute = vm.route = router.parse();
|
||||
updateRender(vm);
|
||||
lastRoute = vm.route;
|
||||
|
||||
router.onchange(function (_) {
|
||||
router.normalize();
|
||||
vm.route = router.parse();
|
||||
updateRender(vm);
|
||||
vm._updateRender();
|
||||
|
||||
if (lastRoute.path === vm.route.path) {
|
||||
@@ -3615,17 +3658,24 @@ function fetchMixin (proto) {
|
||||
// Current page is html
|
||||
this.isHTML = /\.html$/g.test(path);
|
||||
|
||||
// Load main content
|
||||
last.then(function (text, opt) {
|
||||
this$1._renderMain(text, opt);
|
||||
var loadSideAndNav = function () {
|
||||
if (!loadSidebar) { return cb() }
|
||||
|
||||
var fn = function (result) { this$1._renderSidebar(result); cb(); };
|
||||
|
||||
// Load sidebar
|
||||
loadNested(path, loadSidebar, fn, this$1, true);
|
||||
};
|
||||
|
||||
// Load main content
|
||||
last.then(function (text, opt) {
|
||||
this$1._renderMain(text, opt);
|
||||
loadSideAndNav();
|
||||
},
|
||||
function (_) { return this$1._renderMain(null); });
|
||||
function (_) {
|
||||
this$1._renderMain(null);
|
||||
loadSideAndNav();
|
||||
});
|
||||
|
||||
// Load nav
|
||||
loadNavbar &&
|
||||
@@ -3750,7 +3800,7 @@ initGlobalAPI();
|
||||
/**
|
||||
* Version
|
||||
*/
|
||||
Docsify.version = '4.1.11';
|
||||
Docsify.version = '4.2.1';
|
||||
|
||||
/**
|
||||
* Run Docsify
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
@@ -1,4 +1,3 @@
|
||||
this.D = this.D || {};
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,4 +1,3 @@
|
||||
this.D = this.D || {};
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
this.D=this.D||{},function(){"use strict";function e(){for(var e=Docsify.dom.getNode("#main"),i=Docsify.dom.findAll(e,"script"),o=i.length;o--;){var t=i[o];if(t&&t.src){var n=document.createElement("script");Array.prototype.slice.call(t.attributes).forEach(function(e){n[e.name]=e.value}),t.parentNode.insertBefore(n,t),t.parentNode.removeChild(t)}}}var i=function(i){i.doneEach(e)};window.$docsify.plugins=[].concat(i,window.$docsify.plugins)}();
|
||||
!function(){"use strict";function e(){for(var e=Docsify.dom.getNode("#main"),o=Docsify.dom.findAll(e,"script"),n=o.length;n--;){var i=o[n];if(i&&i.src){var t=document.createElement("script");Array.prototype.slice.call(i.attributes).forEach(function(e){t[e.name]=e.value}),i.parentNode.insertBefore(t,i),i.parentNode.removeChild(i)}}}var o=function(o){o.doneEach(e)};window.$docsify.plugins=[].concat(o,window.$docsify.plugins)}();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
this.D = this.D || {};
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+11
-15
@@ -1,4 +1,3 @@
|
||||
this.D = this.D || {};
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
@@ -11,24 +10,21 @@ function appendScript () {
|
||||
}
|
||||
|
||||
function init (id) {
|
||||
var ga = window.ga;
|
||||
|
||||
if (!ga) {
|
||||
appendScript();
|
||||
ga = ga || function () {
|
||||
(ga.q = ga.q || []).push(arguments);
|
||||
};
|
||||
ga.l = Number(new Date());
|
||||
ga('create', id, 'auto');
|
||||
}
|
||||
return ga
|
||||
appendScript();
|
||||
window.ga = window.ga || function () {
|
||||
(window.ga.q = window.ga.q || []).push(arguments);
|
||||
};
|
||||
window.ga.l = Number(new Date());
|
||||
window.ga('create', id, 'auto');
|
||||
}
|
||||
|
||||
function collect () {
|
||||
var ga = init($docsify.ga);
|
||||
if (!window.ga) {
|
||||
init($docsify.ga);
|
||||
}
|
||||
|
||||
ga('set', 'page', location.hash);
|
||||
ga('send', 'pageview');
|
||||
window.ga('set', 'page', location.hash);
|
||||
window.ga('send', 'pageview');
|
||||
}
|
||||
|
||||
var install = function (hook) {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
this.D=this.D||{},function(){"use strict";function n(){var n=document.createElement("script");n.async=!0,n.src="https://www.google-analytics.com/analytics.js",document.body.appendChild(n)}function c(c){var e=window.ga;return e||(n(),e=e||function(){(e.q=e.q||[]).push(arguments)},e.l=Number(new Date),e("create",c,"auto")),e}function e(){var n=c($docsify.ga);n("set","page",location.hash),n("send","pageview")}var i=function(n){if(!$docsify.ga)return void console.error("[Docsify] ga is required.");n.beforeEach(e)};$docsify.plugins=[].concat(i,$docsify.plugins)}();
|
||||
!function(){"use strict";function n(){var n=document.createElement("script");n.async=!0,n.src="https://www.google-analytics.com/analytics.js",document.body.appendChild(n)}function o(o){n(),window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=Number(new Date),window.ga("create",o,"auto")}function i(){window.ga||o($docsify.ga),window.ga("set","page",location.hash),window.ga("send","pageview")}var a=function(n){if(!$docsify.ga)return void console.error("[Docsify] ga is required.");n.beforeEach(i)};$docsify.plugins=[].concat(a,$docsify.plugins)}();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
this.D = this.D || {};
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(e){var n=[];return h.dom.findAll("a:not([data-nosearch])").map(function(t){var o=t.href,i=t.getAttribute("href"),r=e.parse(o).path;r&&-1===n.indexOf(r)&&!Docsify.util.isAbsolutePath(i)&&n.push(r)}),n}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(y))}function o(e,n,t){void 0===n&&(n="");var o,i=window.marked.lexer(n),r=window.Docsify.slugify,a={};return i.forEach(function(n){if("heading"===n.type&&n.depth<=2)o=t.toURL(e,{id:r(n.text)}),a[o]={slug:o,title:n.text,body:""};else{if(!o)return;a[o]?a[o].body?a[o].body+="\n"+(n.text||""):a[o].body=n.text:a[o]={slug:o,title:"",body:""}}}),r.clear(),a}function i(n){var t=[],o=[];Object.keys(y).forEach(function(e){o=o.concat(Object.keys(y[e]).map(function(n){return y[e][n]}))}),n=[].concat(n,n.trim().split(/[\s\-\,\\\/]+/));for(var i=0;i<o.length;i++)!function(i){var r=o[i],a=!1,s="",c=r.title&&r.title.trim(),f=r.body&&r.body.trim(),l=r.slug||"";if(c&&f&&(n.forEach(function(n,t){var o=new RegExp(n,"gi"),i=-1,r=-1;if(i=c&&c.search(o),r=f&&f.search(o),i<0&&r<0)a=!1;else{a=!0,r<0&&(r=0);var l=0,d=0;l=r<11?0:r-10,d=0===l?70:r+n.length+60,d>f.length&&(d=f.length);var u="..."+e(f).substring(l,d).replace(o,'<em class="search-keyword">'+n+"</em>")+"...";s+=u}}),a)){var d={title:e(c),content:s,url:l};t.push(d)}}(i);return t}function r(e,i){h=Docsify;var r="auto"===e.paths,a=localStorage.getItem("docsify.search.expires")<Date.now();if(y=JSON.parse(localStorage.getItem("docsify.search.index")),a)y={};else if(!r)return;var s=r?n(i.router):e.paths,c=s.length,f=0;s.forEach(function(n){if(y[n])return f++;h.get(i.router.getFile(n)).then(function(r){y[n]=o(n,r,i.router),c===++f&&t(e.maxAge)})})}function a(){var e=Docsify.dom.create("style","\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}");Docsify.dom.appendTo(Docsify.dom.head,e)}function s(e,n){void 0===n&&(n="");var t='<input type="search" value="'+n+'" /><div class="results-panel"></div></div>',o=Docsify.dom.create("div",t),i=Docsify.dom.find("aside");Docsify.dom.toggleClass(o,"search"),Docsify.dom.before(i,o)}function c(e){var n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,".results-panel");if(!e)return t.classList.remove("show"),void(t.innerHTML="");var o=i(e),r="";o.forEach(function(e){r+='<div class="matching-post">\n<h2><a href="'+e.url+'">'+e.title+"</a></h2>\n<p>"+e.content+"</p>\n</div>"}),t.classList.add("show"),t.innerHTML=r||'<p class="empty">'+m+"</p>"}function f(){var e,n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,"input");Docsify.dom.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),Docsify.dom.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return c(n.target.value.trim())},100)})}function l(e,n){var t=Docsify.dom.getNode('.search input[type="search"]');if(t)if("string"==typeof e)t.placeholder=e;else{var o=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];t.placeholder=e[o]}}function d(e,n){if("string"==typeof e)m=e;else{var t=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];m=e[t]}}function u(e,n){var t=n.router.parse().query.s;a(),s(e,t),f(),t&&setTimeout(function(e){return c(t)},500)}function p(e,n){l(e.placeholder,n.route.path),d(e.noData,n.route.path)}var h,y={},m="",g={placeholder:"Type to search",noData:"No Results!",paths:"auto",maxAge:864e5},v=function(e,n){var t=Docsify.util,o=n.config.search||g;Array.isArray(o)?g.paths=o:"object"==typeof o&&(g.paths=Array.isArray(o.paths)?o.paths:"auto",g.maxAge=t.isPrimitive(o.maxAge)?o.maxAge:g.maxAge,g.placeholder=o.placeholder||g.placeholder,g.noData=o.noData||g.noData);var i="auto"===g.paths;e.mounted(function(e){u(g,n),!i&&r(g,n)}),e.doneEach(function(e){p(g,n),i&&r(g,n)})};$docsify.plugins=[].concat(v,$docsify.plugins)}();
|
||||
!function(){"use strict";function e(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(e){var n=[];return h.dom.findAll("a:not([data-nosearch])").map(function(t){var o=t.href,i=t.getAttribute("href"),r=e.parse(o).path;r&&-1===n.indexOf(r)&&!Docsify.util.isAbsolutePath(i)&&n.push(r)}),n}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(y))}function o(e,n,t){void 0===n&&(n="");var o,i=window.marked.lexer(n),r=window.Docsify.slugify,a={};return i.forEach(function(n){if("heading"===n.type&&n.depth<=2)o=t.toURL(e,{id:r(n.text)}),a[o]={slug:o,title:n.text,body:""};else{if(!o)return;a[o]?a[o].body?a[o].body+="\n"+(n.text||""):a[o].body=n.text:a[o]={slug:o,title:"",body:""}}}),r.clear(),a}function i(n){var t=[],o=[];Object.keys(y).forEach(function(e){o=o.concat(Object.keys(y[e]).map(function(n){return y[e][n]}))}),n=[].concat(n,n.trim().split(/[\s\-\,\\\/]+/));for(var i=0;i<o.length;i++)!function(i){var r=o[i],a=!1,s="",c=r.title&&r.title.trim(),f=r.body&&r.body.trim(),l=r.slug||"";if(c&&f&&(n.forEach(function(n,t){var o=new RegExp(n,"gi"),i=-1,r=-1;if(i=c&&c.search(o),r=f&&f.search(o),i<0&&r<0)a=!1;else{a=!0,r<0&&(r=0);var l=0,d=0;l=r<11?0:r-10,d=0===l?70:r+n.length+60,d>f.length&&(d=f.length);var u="..."+e(f).substring(l,d).replace(o,'<em class="search-keyword">'+n+"</em>")+"...";s+=u}}),a)){var d={title:e(c),content:s,url:l};t.push(d)}}(i);return t}function r(e,i){h=Docsify;var r="auto"===e.paths,a=localStorage.getItem("docsify.search.expires")<Date.now();if(y=JSON.parse(localStorage.getItem("docsify.search.index")),a)y={};else if(!r)return;var s=r?n(i.router):e.paths,c=s.length,f=0;s.forEach(function(n){if(y[n])return f++;h.get(i.router.getFile(n)).then(function(r){y[n]=o(n,r,i.router),c===++f&&t(e.maxAge)})})}function a(){var e=Docsify.dom.create("style","\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}");Docsify.dom.appendTo(Docsify.dom.head,e)}function s(e,n){void 0===n&&(n="");var t='<input type="search" value="'+n+'" /><div class="results-panel"></div></div>',o=Docsify.dom.create("div",t),i=Docsify.dom.find("aside");Docsify.dom.toggleClass(o,"search"),Docsify.dom.before(i,o)}function c(e){var n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,".results-panel");if(!e)return t.classList.remove("show"),void(t.innerHTML="");var o=i(e),r="";o.forEach(function(e){r+='<div class="matching-post">\n<h2><a href="'+e.url+'">'+e.title+"</a></h2>\n<p>"+e.content+"</p>\n</div>"}),t.classList.add("show"),t.innerHTML=r||'<p class="empty">'+m+"</p>"}function f(){var e,n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,"input");Docsify.dom.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),Docsify.dom.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return c(n.target.value.trim())},100)})}function l(e,n){var t=Docsify.dom.getNode('.search input[type="search"]');if(t)if("string"==typeof e)t.placeholder=e;else{var o=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];t.placeholder=e[o]}}function d(e,n){if("string"==typeof e)m=e;else{var t=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];m=e[t]}}function u(e,n){var t=n.router.parse().query.s;a(),s(e,t),f(),t&&setTimeout(function(e){return c(t)},500)}function p(e,n){l(e.placeholder,n.route.path),d(e.noData,n.route.path)}var h,y={},m="",g={placeholder:"Type to search",noData:"No Results!",paths:"auto",maxAge:864e5},v=function(e,n){var t=Docsify.util,o=n.config.search||g;Array.isArray(o)?g.paths=o:"object"==typeof o&&(g.paths=Array.isArray(o.paths)?o.paths:"auto",g.maxAge=t.isPrimitive(o.maxAge)?o.maxAge:g.maxAge,g.placeholder=o.placeholder||g.placeholder,g.noData=o.noData||g.noData);var i="auto"===g.paths;e.mounted(function(e){u(g,n),!i&&r(g,n)}),e.doneEach(function(e){p(g,n),i&&r(g,n)})};$docsify.plugins=[].concat(v,$docsify.plugins)}();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
this.D = this.D || {};
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
this.D=this.D||{},function(){"use strict";function t(t){var o,i=Docsify.dom;i.appendTo(i.head,i.create("style",n)),t.doneEach(function(t){var n=i.findAll("img:not(.emoji)");Array.isArray(o)&&o.length&&(o.forEach(function(t){return t()}),o=[]),o=n.map(e)})}var e=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self,function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t,e){!function(e,n){t.exports=function(){function t(){-1===g&&(g=window.pageYOffset),Math.abs(g-window.pageYOffset)>=40&&a()}function e(t){27===t.keyCode&&a()}function n(t){var e=t.touches[0];null!==e&&(y=e.pageY,t.target.addEventListener("touchmove",o))}function o(t){var e=t.touches[0];null!==e&&Math.abs(e.pageY-y)>10&&(a(),t.target.removeEventListener("touchmove",o))}function i(){a()}function r(){document.addEventListener("scroll",t),document.addEventListener("keyup",e),document.addEventListener("touchstart",n),document.addEventListener("click",i,!0)}function s(){document.removeEventListener("scroll",t),document.removeEventListener("keyup",e),document.removeEventListener("touchstart",n),document.removeEventListener("click",i,!0)}function a(t){null!==h&&(t?h.dispose():h.close(),s(),h=null)}function c(t){if(!document.body.classList.contains("zoom-overlay-open"))return t.metaKey||t.ctrlKey?void window.open(t.target.getAttribute("data-original")||t.target.src,"_blank"):void(t.target.width>=m()-v||(a(!0),h=new p(t.target,v),h.zoom(),r()))}var m=function(){return document.documentElement.clientWidth},u=function(){return document.documentElement.clientHeight},d=function(t){var e=t.getBoundingClientRect(),n=document.documentElement,o=window;return{top:e.top+o.pageYOffset-n.clientTop,left:e.left+o.pageXOffset-n.clientLeft}},l=function(t,e,n){var o=function(t){t.target.removeEventListener(e,o),n()};t.addEventListener(e,o)},f=function(t,e){this.w=t,this.h=e},p=function(t,e){this.img=t,this.preservedTransform=t.style.transform,this.wrap=null,this.overlay=null,this.offset=e};p.prototype.forceRepaint=function(){this.img.offsetWidth},p.prototype.zoom=function(){var t=new f(this.img.naturalWidth,this.img.naturalHeight);this.wrap=document.createElement("div"),this.wrap.classList.add("zoom-img-wrap"),this.img.parentNode.insertBefore(this.wrap,this.img),this.wrap.appendChild(this.img),this.img.classList.add("zoom-img"),this.img.setAttribute("data-action","zoom-out"),this.overlay=document.createElement("div"),this.overlay.classList.add("zoom-overlay"),document.body.appendChild(this.overlay),this.forceRepaint();var e=this.calculateScale(t);this.forceRepaint(),this.animate(e),document.body.classList.add("zoom-overlay-open")},p.prototype.calculateScale=function(t){var e=t.w/this.img.width,n=m()-this.offset,o=u()-this.offset,i=t.w/t.h,r=n/o;return t.w<n&&t.h<o?e:i<r?o/t.h*e:n/t.w*e},p.prototype.animate=function(t){var e=d(this.img),n=window.pageYOffset,o=m()/2,i=n+u()/2,r=e.left+this.img.width/2,s=e.top+this.img.height/2,a=o-r,c=i-s,l="scale("+t+")",f="translate3d("+a+"px, "+c+"px, 0px)";this.img.style.transform=l,this.wrap.style.transform=f},p.prototype.dispose=function(){null!==this.wrap&&null!==this.wrap.parentNode&&(this.img.classList.remove("zoom-img"),this.img.setAttribute("data-action","zoom"),this.wrap.parentNode.insertBefore(this.img,this.wrap),this.wrap.parentNode.removeChild(this.wrap),document.body.removeChild(this.overlay),document.body.classList.remove("zoom-overlay-transitioning"))},p.prototype.close=function(){var t=this;document.body.classList.add("zoom-overlay-transitioning"),this.img.style.transform=this.preservedTransform,0===this.img.style.length&&this.img.removeAttribute("style"),this.wrap.style.transform="none",l(this.img,"transitionend",function(){t.dispose(),document.body.classList.remove("zoom-overlay-open")})};var h=null,v=80,g=-1,y=-1;return function(t){return t.setAttribute("data-action","zoom"),t.addEventListener("click",c),function(){return t.removeEventListener("click",c)}}}()}()})),n='img[data-action="zoom"] {\n cursor: pointer;\n cursor: -webkit-zoom-in;\n cursor: zoom-in;\n}\n.zoom-img,\n.zoom-img-wrap {\n position: relative;\n z-index: 666;\n transition: -webkit-transform 300ms cubic-bezier(.2,0,.2,1);\n transition: transform 300ms cubic-bezier(.2,0,.2,1);\n transition: transform 300ms cubic-bezier(.2,0,.2,1), -webkit-transform 300ms cubic-bezier(.2,0,.2,1);\n}\n.zoom-overlay {\n z-index: 420;\n background: #fff;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n opacity: 0;\n transition: opacity 300ms;\n}\n.zoom-overlay-open .zoom-overlay {\n opacity: 1;\n}\n.zoom-overlay-open {\n cursor: pointer;\n cursor: -webkit-zoom-out;\n cursor: zoom-out;\n}\n.zoom-overlay-transitioning {\n cursor: default;\n}\n.zoom-overlay-open.zoom-overlay-transitioning .zoom-overlay{\n opacity: 0;\n}\n';$docsify.plugins=[].concat(t,$docsify.plugins)}();
|
||||
!function(){"use strict";function t(t){var o,i=Docsify.dom;i.appendTo(i.head,i.create("style",n)),t.doneEach(function(t){var n=i.findAll("img:not(.emoji)");Array.isArray(o)&&o.length&&(o.forEach(function(t){return t()}),o=[]),o=n.map(e)})}var e=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self,function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t,e){!function(e,n){t.exports=function(){function t(){-1===g&&(g=window.pageYOffset),Math.abs(g-window.pageYOffset)>=40&&a()}function e(t){27===t.keyCode&&a()}function n(t){var e=t.touches[0];null!==e&&(y=e.pageY,t.target.addEventListener("touchmove",o))}function o(t){var e=t.touches[0];null!==e&&Math.abs(e.pageY-y)>10&&(a(),t.target.removeEventListener("touchmove",o))}function i(){a()}function r(){document.addEventListener("scroll",t),document.addEventListener("keyup",e),document.addEventListener("touchstart",n),document.addEventListener("click",i,!0)}function s(){document.removeEventListener("scroll",t),document.removeEventListener("keyup",e),document.removeEventListener("touchstart",n),document.removeEventListener("click",i,!0)}function a(t){null!==h&&(t?h.dispose():h.close(),s(),h=null)}function c(t){if(!document.body.classList.contains("zoom-overlay-open"))return t.metaKey||t.ctrlKey?void window.open(t.target.getAttribute("data-original")||t.target.src,"_blank"):void(t.target.width>=m()-v||(a(!0),h=new p(t.target,v),h.zoom(),r()))}var m=function(){return document.documentElement.clientWidth},u=function(){return document.documentElement.clientHeight},d=function(t){var e=t.getBoundingClientRect(),n=document.documentElement,o=window;return{top:e.top+o.pageYOffset-n.clientTop,left:e.left+o.pageXOffset-n.clientLeft}},l=function(t,e,n){var o=function(t){t.target.removeEventListener(e,o),n()};t.addEventListener(e,o)},f=function(t,e){this.w=t,this.h=e},p=function(t,e){this.img=t,this.preservedTransform=t.style.transform,this.wrap=null,this.overlay=null,this.offset=e};p.prototype.forceRepaint=function(){this.img.offsetWidth},p.prototype.zoom=function(){var t=new f(this.img.naturalWidth,this.img.naturalHeight);this.wrap=document.createElement("div"),this.wrap.classList.add("zoom-img-wrap"),this.img.parentNode.insertBefore(this.wrap,this.img),this.wrap.appendChild(this.img),this.img.classList.add("zoom-img"),this.img.setAttribute("data-action","zoom-out"),this.overlay=document.createElement("div"),this.overlay.classList.add("zoom-overlay"),document.body.appendChild(this.overlay),this.forceRepaint();var e=this.calculateScale(t);this.forceRepaint(),this.animate(e),document.body.classList.add("zoom-overlay-open")},p.prototype.calculateScale=function(t){var e=t.w/this.img.width,n=m()-this.offset,o=u()-this.offset,i=t.w/t.h,r=n/o;return t.w<n&&t.h<o?e:i<r?o/t.h*e:n/t.w*e},p.prototype.animate=function(t){var e=d(this.img),n=window.pageYOffset,o=m()/2,i=n+u()/2,r=e.left+this.img.width/2,s=e.top+this.img.height/2,a=o-r,c=i-s,l="scale("+t+")",f="translate3d("+a+"px, "+c+"px, 0px)";this.img.style.transform=l,this.wrap.style.transform=f},p.prototype.dispose=function(){null!==this.wrap&&null!==this.wrap.parentNode&&(this.img.classList.remove("zoom-img"),this.img.setAttribute("data-action","zoom"),this.wrap.parentNode.insertBefore(this.img,this.wrap),this.wrap.parentNode.removeChild(this.wrap),document.body.removeChild(this.overlay),document.body.classList.remove("zoom-overlay-transitioning"))},p.prototype.close=function(){var t=this;document.body.classList.add("zoom-overlay-transitioning"),this.img.style.transform=this.preservedTransform,0===this.img.style.length&&this.img.removeAttribute("style"),this.wrap.style.transform="none",l(this.img,"transitionend",function(){t.dispose(),document.body.classList.remove("zoom-overlay-open")})};var h=null,v=80,g=-1,y=-1;return function(t){return t.setAttribute("data-action","zoom"),t.addEventListener("click",c),function(){return t.removeEventListener("click",c)}}}()}()})),n='img[data-action="zoom"] {\n cursor: pointer;\n cursor: -webkit-zoom-in;\n cursor: zoom-in;\n}\n.zoom-img,\n.zoom-img-wrap {\n position: relative;\n z-index: 666;\n transition: -webkit-transform 300ms cubic-bezier(.2,0,.2,1);\n transition: transform 300ms cubic-bezier(.2,0,.2,1);\n transition: transform 300ms cubic-bezier(.2,0,.2,1), -webkit-transform 300ms cubic-bezier(.2,0,.2,1);\n}\n.zoom-overlay {\n z-index: 420;\n background: #fff;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n opacity: 0;\n transition: opacity 300ms;\n}\n.zoom-overlay-open .zoom-overlay {\n opacity: 1;\n}\n.zoom-overlay-open {\n cursor: pointer;\n cursor: -webkit-zoom-out;\n cursor: zoom-out;\n}\n.zoom-overlay-transitioning {\n cursor: default;\n}\n.zoom-overlay-open.zoom-overlay-transitioning .zoom-overlay{\n opacity: 0;\n}\n';$docsify.plugins=[].concat(t,$docsify.plugins)}();
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Generated
+83
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify",
|
||||
"version": "4.1.11",
|
||||
"version": "4.2.1",
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"abbrev": {
|
||||
@@ -1316,6 +1316,12 @@
|
||||
"integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=",
|
||||
"dev": true
|
||||
},
|
||||
"fs-access": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz",
|
||||
"integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=",
|
||||
"dev": true
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz",
|
||||
@@ -3089,6 +3095,12 @@
|
||||
"integrity": "sha1-mSms32KPwsQQmN6rgqxYDPFJquQ=",
|
||||
"dev": true
|
||||
},
|
||||
"null-check": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz",
|
||||
"integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=",
|
||||
"dev": true
|
||||
},
|
||||
"num2fraction": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz",
|
||||
@@ -4390,12 +4402,82 @@
|
||||
"integrity": "sha1-eh9VHhdqkOzTNF9yRqDP4XXvT9A=",
|
||||
"dev": true
|
||||
},
|
||||
"sprintf": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/sprintf/-/sprintf-0.1.5.tgz",
|
||||
"integrity": "sha1-j4PjmpMXwaUCy324BQ5Rxnn27c8=",
|
||||
"dev": true
|
||||
},
|
||||
"sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
||||
"dev": true
|
||||
},
|
||||
"standard-changelog": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/standard-changelog/-/standard-changelog-1.0.2.tgz",
|
||||
"integrity": "sha512-DMQPuUsVtSLYSilSSpjVHZGzViLc8ZjoSwPwPjasauvqI4WH6sKLknVxdF/610Gt7V/nhQMtck3vi+FBqPkS5w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"conventional-changelog-angular": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-1.4.0.tgz",
|
||||
"integrity": "sha512-ukKX22lJl9ewogze1hKbBuff/dGMG2uyGpOhhw0ehhlv6GtdeCxj51YfGOZ5qC89WwsHT7SDXFzBKidwH3pwmQ==",
|
||||
"dev": true
|
||||
},
|
||||
"conventional-changelog-core": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-1.9.0.tgz",
|
||||
"integrity": "sha1-3l37wJGEdlZQjUo4njXJobxJ5/Q=",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"find-up": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
|
||||
"integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
|
||||
"dev": true
|
||||
},
|
||||
"read-pkg": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
|
||||
"integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=",
|
||||
"dev": true
|
||||
},
|
||||
"read-pkg-up": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz",
|
||||
"integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"load-json-file": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
|
||||
"integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
|
||||
"dev": true
|
||||
},
|
||||
"path-exists": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
|
||||
"integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
|
||||
"dev": true
|
||||
},
|
||||
"read-pkg-up": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz",
|
||||
"integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=",
|
||||
"dev": true
|
||||
},
|
||||
"strip-bom": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
|
||||
"integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"statuses": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz",
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify",
|
||||
"version": "4.1.11",
|
||||
"version": "4.2.1",
|
||||
"description": "A magical documentation generator.",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
@@ -52,7 +52,8 @@
|
||||
"rollup-plugin-replace": "^1.1.1",
|
||||
"rollup-plugin-string": "^2.0.2",
|
||||
"rollup-plugin-uglify": "^1.0.1",
|
||||
"serve-static": "^1.12.1"
|
||||
"serve-static": "^1.12.1",
|
||||
"standard-changelog": "^1.0.2"
|
||||
},
|
||||
"keywords": [
|
||||
"doc",
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.8",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
|
||||
"integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw="
|
||||
},
|
||||
"encoding": {
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
|
||||
"integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s="
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.18",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz",
|
||||
"integrity": "sha512-sr1ZQph3UwHTR0XftSbK85OvBbxe/abLGzEnPENCQwmHf7sck8Oyu4ob3LgBxWWxRoM+QszeUyl7jbqapu2TqA=="
|
||||
},
|
||||
"is-stream": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
|
||||
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.1.tgz",
|
||||
"integrity": "sha512-j8XsFGCLw79vWXkZtMSmmLaOk9z5SQ9bV/tkbZVCqvgwzrjAGq66igobLofHtF63NvMTp2WjytpsNTGKa+XRIQ=="
|
||||
},
|
||||
"resolve-pathname": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-2.1.0.tgz",
|
||||
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
||||
}
|
||||
},
|
||||
"version": "4.2.1"
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify-server-renderer",
|
||||
"version": "4.1.11",
|
||||
"version": "4.2.1",
|
||||
"description": "docsify server renderer",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@ const config = merge({
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerModel: 'hash'
|
||||
routerModel: 'hash',
|
||||
noCompileLinks: []
|
||||
}, window.$docsify)
|
||||
|
||||
const script = document.currentScript ||
|
||||
|
||||
+11
-4
@@ -28,17 +28,24 @@ export function fetchMixin (proto) {
|
||||
// Current page is html
|
||||
this.isHTML = /\.html$/g.test(path)
|
||||
|
||||
// Load main content
|
||||
last.then((text, opt) => {
|
||||
this._renderMain(text, opt)
|
||||
const loadSideAndNav = () => {
|
||||
if (!loadSidebar) return cb()
|
||||
|
||||
const fn = result => { this._renderSidebar(result); cb() }
|
||||
|
||||
// Load sidebar
|
||||
loadNested(path, loadSidebar, fn, this, true)
|
||||
}
|
||||
|
||||
// Load main content
|
||||
last.then((text, opt) => {
|
||||
this._renderMain(text, opt)
|
||||
loadSideAndNav()
|
||||
},
|
||||
_ => this._renderMain(null))
|
||||
_ => {
|
||||
this._renderMain(null)
|
||||
loadSideAndNav()
|
||||
})
|
||||
|
||||
// Load nav
|
||||
loadNavbar &&
|
||||
|
||||
@@ -7,6 +7,8 @@ import { emojify } from './emojify'
|
||||
import { isAbsolutePath, getPath } from '../router/util'
|
||||
import { isFn, merge, cached } from '../util/core'
|
||||
|
||||
const cachedLinks = {}
|
||||
|
||||
export class Compiler {
|
||||
constructor (config, router) {
|
||||
this.config = config
|
||||
@@ -42,6 +44,19 @@ export class Compiler {
|
||||
})
|
||||
}
|
||||
|
||||
matchNotCompileLink (link) {
|
||||
const links = this.config.noCompileLinks
|
||||
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
const n = links[i]
|
||||
const re = cachedLinks[n] || (cachedLinks[n] = new RegExp(`^${n}$`))
|
||||
|
||||
if (re.test(link)) {
|
||||
return link
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_initRenderer () {
|
||||
const renderer = new marked.Renderer()
|
||||
const { linkTarget, router, contentBase } = this
|
||||
@@ -80,11 +95,16 @@ export class Compiler {
|
||||
}
|
||||
renderer.link = function (href, title, text) {
|
||||
let blank = ''
|
||||
if (!/:|(\/{2})/.test(href)) {
|
||||
|
||||
if (!/:|(\/{2})/.test(href) &&
|
||||
!_self.matchNotCompileLink(href) &&
|
||||
!/(\s?:ignore)(\s\S+)?$/.test(title)) {
|
||||
href = router.toURL(href, null, router.getCurrentPath())
|
||||
} else {
|
||||
blank = ` target="${linkTarget}"`
|
||||
title = title && title.replace(/:ignore/g, '').trim()
|
||||
}
|
||||
|
||||
if (title) {
|
||||
title = ` title="${title}"`
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export function renderMixin (proto) {
|
||||
this._renderTo('.sidebar-nav', this.compiler.sidebar(text, maxLevel))
|
||||
const activeEl = getAndActive(this.router, '.sidebar-nav', true, true)
|
||||
if (loadSidebar && activeEl) {
|
||||
activeEl.parentNode.innerHTML += this.compiler.subSidebar(subMaxLevel)
|
||||
activeEl.parentNode.innerHTML += (this.compiler.subSidebar(subMaxLevel) || '')
|
||||
} else {
|
||||
// reset toc
|
||||
this.compiler.subSidebar()
|
||||
@@ -117,6 +117,10 @@ export function renderMixin (proto) {
|
||||
}
|
||||
|
||||
proto._renderMain = function (text, opt = {}) {
|
||||
if (!text) {
|
||||
return renderMain.call(this, text)
|
||||
}
|
||||
|
||||
callHook(this, 'beforeEach', text, result => {
|
||||
let html = this.isHTML ? result : this.compiler.compile(result)
|
||||
if (opt.updatedAt) {
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { getPath, isAbsolutePath } from '../util'
|
||||
import { noop } from '../../util/core'
|
||||
|
||||
function getAlias (path, alias) {
|
||||
return alias[path] ? getAlias(alias[path], alias) : path
|
||||
const cached = {}
|
||||
|
||||
function getAlias (path, alias, last) {
|
||||
const match = Object.keys(alias).filter((key) => {
|
||||
const re = cached[key] || (cached[key] = new RegExp(`^${key}$`))
|
||||
return re.test(path) && path !== last
|
||||
})[0]
|
||||
|
||||
return match ? getAlias(path.replace(cached[match], alias[match]), alias, path) : path
|
||||
}
|
||||
|
||||
function getFileName (path) {
|
||||
@@ -22,7 +29,7 @@ export class History {
|
||||
return this.config.basePath
|
||||
}
|
||||
|
||||
getFile (path) {
|
||||
getFile (path, isRelative) {
|
||||
path = path || this.getCurrentPath()
|
||||
|
||||
const { config } = this
|
||||
@@ -33,6 +40,10 @@ export class History {
|
||||
path = path === '/README.md' ? (config.homepage || path) : path
|
||||
path = isAbsolutePath(path) ? path : getPath(base, path)
|
||||
|
||||
if (isRelative) {
|
||||
path = path.replace(new RegExp(`^${base}`), '')
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ export class HashHistory extends History {
|
||||
|
||||
return {
|
||||
path,
|
||||
file: this.getFile(path),
|
||||
file: this.getFile(path, true),
|
||||
query: parseQuery(query)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { HashHistory } from './history/hash'
|
||||
import { HTML5History } from './history/html5'
|
||||
import { supportsPushState } from '../util/env'
|
||||
import * as dom from '../util/dom'
|
||||
|
||||
export function routerMixin (proto) {
|
||||
proto.route = {}
|
||||
@@ -8,6 +9,12 @@ export function routerMixin (proto) {
|
||||
|
||||
let lastRoute = {}
|
||||
|
||||
function updateRender (vm) {
|
||||
vm.router.normalize()
|
||||
vm.route = vm.router.parse()
|
||||
dom.body.setAttribute('data-page', vm.route.file)
|
||||
}
|
||||
|
||||
export function initRouter (vm) {
|
||||
const config = vm.config
|
||||
const mode = config.routerMode || 'hash'
|
||||
@@ -20,13 +27,11 @@ export function initRouter (vm) {
|
||||
}
|
||||
|
||||
vm.router = router
|
||||
|
||||
router.normalize()
|
||||
lastRoute = vm.route = router.parse()
|
||||
updateRender(vm)
|
||||
lastRoute = vm.route
|
||||
|
||||
router.onchange(_ => {
|
||||
router.normalize()
|
||||
vm.route = router.parse()
|
||||
updateRender(vm)
|
||||
vm._updateRender()
|
||||
|
||||
if (lastRoute.path === vm.route.path) {
|
||||
|
||||
@@ -16,8 +16,9 @@ export function parseQuery (query) {
|
||||
query.split('&').forEach(function (param) {
|
||||
const parts = param.replace(/\+/g, ' ').split('=')
|
||||
|
||||
res[parts[0]] = decode(parts[1])
|
||||
res[parts[0]] = parts[1] && decode(parts[1])
|
||||
})
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -25,7 +26,9 @@ export function stringifyQuery (obj) {
|
||||
const qs = []
|
||||
|
||||
for (const key in obj) {
|
||||
qs.push(`${encode(key)}=${encode(obj[key])}`.toLowerCase())
|
||||
qs.push(obj[key]
|
||||
? `${encode(key)}=${encode(obj[key])}`.toLowerCase()
|
||||
: encode(key))
|
||||
}
|
||||
|
||||
return qs.length ? `?${qs.join('&')}` : ''
|
||||
|
||||
+10
-13
@@ -7,24 +7,21 @@ function appendScript () {
|
||||
}
|
||||
|
||||
function init (id) {
|
||||
let ga = window.ga
|
||||
|
||||
if (!ga) {
|
||||
appendScript()
|
||||
ga = ga || function () {
|
||||
(ga.q = ga.q || []).push(arguments)
|
||||
}
|
||||
ga.l = Number(new Date())
|
||||
ga('create', id, 'auto')
|
||||
appendScript()
|
||||
window.ga = window.ga || function () {
|
||||
(window.ga.q = window.ga.q || []).push(arguments)
|
||||
}
|
||||
return ga
|
||||
window.ga.l = Number(new Date())
|
||||
window.ga('create', id, 'auto')
|
||||
}
|
||||
|
||||
function collect () {
|
||||
const ga = init($docsify.ga)
|
||||
if (!window.ga) {
|
||||
init($docsify.ga)
|
||||
}
|
||||
|
||||
ga('set', 'page', location.hash)
|
||||
ga('send', 'pageview')
|
||||
window.ga('set', 'page', location.hash)
|
||||
window.ga('send', 'pageview')
|
||||
}
|
||||
|
||||
const install = function (hook) {
|
||||
|
||||
@@ -244,6 +244,10 @@ main {
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
|
||||
Reference in New Issue
Block a user