mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-09 13:26:34 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a961e3b972 | ||
|
|
3c94178805 | ||
|
|
490242fb73 | ||
|
|
5c0de0aefe | ||
|
|
04b36b0ef2 | ||
|
|
3a7ad6299e | ||
|
|
feea7f9b48 | ||
|
|
cd09d91434 | ||
|
|
a5f333a329 | ||
|
|
7dcebe7544 | ||
|
|
cc636e6ca3 | ||
|
|
5523a2a2a9 | ||
|
|
f8f22e5a3c | ||
|
|
ee72dd05e5 | ||
|
|
6c7ebc989d | ||
|
|
57967d2caa | ||
|
|
c2886b1b62 | ||
|
|
2d9e581d63 | ||
|
|
604989ff04 | ||
|
|
26525db433 | ||
|
|
2b0109b89a | ||
|
|
fb144b2e69 | ||
|
|
ac695de859 | ||
|
|
e5a263f1bb | ||
|
|
48e531bcfb | ||
|
|
1f338d2142 | ||
|
|
cf05d7b26c | ||
|
|
cb1a56d89b | ||
|
|
62b7578468 | ||
|
|
410efb2bc2 | ||
|
|
1e99d7b514 | ||
|
|
e4e011c81f | ||
|
|
4cd0e5eb49 | ||
|
|
531e483c31 | ||
|
|
6a3d69ae1a | ||
|
|
ef1b42be23 | ||
|
|
54f45ecb0a | ||
|
|
4c91fbc7cb | ||
|
|
bfd0d18e48 | ||
|
|
74ff68a40e | ||
|
|
e737a42f75 | ||
|
|
a850b29545 | ||
|
|
aeb692ed6b | ||
|
|
01140ceb54 | ||
|
|
87129c0fb2 | ||
|
|
95e95bd23b | ||
|
|
8974f3964e | ||
|
|
75222209da | ||
|
|
8352a1e489 | ||
|
|
9b3b4454de | ||
|
|
0933445e89 | ||
|
|
ec8daca3ec | ||
|
|
1335baa22f | ||
|
|
123c516836 | ||
|
|
ecc0e04c70 | ||
|
|
278a75ebd5 | ||
|
|
b8a4e6ba1b | ||
|
|
01bbbaaf92 | ||
|
|
e5c64a3d8f | ||
|
|
e5ae6e8d25 | ||
|
|
702bb5b715 | ||
|
|
7cdf751cc5 | ||
|
|
6a09059645 | ||
|
|
84f7b5c7c2 |
+4
-2
@@ -1,3 +1,5 @@
|
||||
.git/
|
||||
.git
|
||||
packages/docsify-server-renderer/build.js
|
||||
node_modules
|
||||
node_modules
|
||||
build
|
||||
server.js
|
||||
@@ -1,15 +1,20 @@
|
||||
{
|
||||
"extends": [
|
||||
"vue"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 8
|
||||
},
|
||||
"env": {
|
||||
"browser": true
|
||||
"extends": "xo-space/browser",
|
||||
"rules": {
|
||||
"semi": [2, "never"],
|
||||
"no-return-assign": "off",
|
||||
"no-unused-expressions": "off",
|
||||
"no-new-func": "off",
|
||||
"no-multi-assign": "off",
|
||||
"no-mixed-operators": "off",
|
||||
"max-params": "off",
|
||||
"no-script-url": "off",
|
||||
"camelcase": "off",
|
||||
"no-warning-comments": "off"
|
||||
},
|
||||
"globals": {
|
||||
"Docsify": true,
|
||||
"$docsify": true
|
||||
"$docsify": true,
|
||||
"process": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
/themes/
|
||||
node_modules
|
||||
/lib/
|
||||
.idea
|
||||
+105
@@ -1,3 +1,108 @@
|
||||
<a name="4.7.0"></a>
|
||||
# [4.7.0](https://github.com/QingWei-Li/docsify/compare/v4.6.9...v4.7.0) (2018-06-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* alldow addition content in sidebar, fix [#518](https://github.com/QingWei-Li/docsify/issues/518), fix 539 ([#543](https://github.com/QingWei-Li/docsify/issues/543)) ([04b36b0](https://github.com/QingWei-Li/docsify/commit/04b36b0))
|
||||
* async install config, fixed [#425](https://github.com/QingWei-Li/docsify/issues/425) ([e4e011c](https://github.com/QingWei-Li/docsify/commit/e4e011c))
|
||||
* loading embed files synchronously, fixed [#525](https://github.com/QingWei-Li/docsify/issues/525), fixed [#527](https://github.com/QingWei-Li/docsify/issues/527) ([#544](https://github.com/QingWei-Li/docsify/issues/544)) ([feea7f9](https://github.com/QingWei-Li/docsify/commit/feea7f9))
|
||||
* path include chinese character cause hilight bug ([#556](https://github.com/QingWei-Li/docsify/issues/556)) ([a5f333a](https://github.com/QingWei-Li/docsify/commit/a5f333a))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add logo option, [#264](https://github.com/QingWei-Li/docsify/issues/264) ([#541](https://github.com/QingWei-Li/docsify/issues/541)) ([ee72dd0](https://github.com/QingWei-Li/docsify/commit/ee72dd0))
|
||||
* add unpkg field, close [#531](https://github.com/QingWei-Li/docsify/issues/531) ([#558](https://github.com/QingWei-Li/docsify/issues/558)) ([5c0de0a](https://github.com/QingWei-Li/docsify/commit/5c0de0a))
|
||||
* support image resizing, resolve [#508](https://github.com/QingWei-Li/docsify/issues/508) ([#545](https://github.com/QingWei-Li/docsify/issues/545)) ([3a7ad62](https://github.com/QingWei-Li/docsify/commit/3a7ad62))
|
||||
|
||||
|
||||
|
||||
<a name="4.6.10"></a>
|
||||
## [4.6.10](https://github.com/QingWei-Li/docsify/compare/v4.6.9...v4.6.10) (2018-03-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* async install config, fixed [#425](https://github.com/QingWei-Li/docsify/issues/425) ([e4e011c](https://github.com/QingWei-Li/docsify/commit/e4e011c))
|
||||
|
||||
|
||||
|
||||
<a name="4.6.9"></a>
|
||||
## [4.6.9](https://github.com/QingWei-Li/docsify/compare/v4.6.8...v4.6.9) (2018-03-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* upgrade medium-zoom, fixed [#417](https://github.com/QingWei-Li/docsify/issues/417) ([6a3d69a](https://github.com/QingWei-Li/docsify/commit/6a3d69a))
|
||||
|
||||
|
||||
|
||||
<a name="4.6.8"></a>
|
||||
## [4.6.8](https://github.com/QingWei-Li/docsify/compare/v4.6.7...v4.6.8) (2018-03-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* resolve path of image and embed files, fixed [#412](https://github.com/QingWei-Li/docsify/issues/412) ([bfd0d18](https://github.com/QingWei-Li/docsify/commit/bfd0d18))
|
||||
|
||||
|
||||
|
||||
<a name="4.6.7"></a>
|
||||
## [4.6.7](https://github.com/QingWei-Li/docsify/compare/v4.6.6...v4.6.7) (2018-03-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* layout css, fixed [#409](https://github.com/QingWei-Li/docsify/issues/409) ([aeb692e](https://github.com/QingWei-Li/docsify/commit/aeb692e))
|
||||
|
||||
|
||||
|
||||
<a name="4.6.6"></a>
|
||||
## [4.6.6](https://github.com/QingWei-Li/docsify/compare/v4.6.5...v4.6.6) (2018-03-03)
|
||||
|
||||
|
||||
|
||||
<a name="4.6.5"></a>
|
||||
## [4.6.5](https://github.com/QingWei-Li/docsify/compare/v4.6.4...v4.6.5) (2018-03-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **navbar:** Now Navbar isn't append to DOM when loadNavbar is falsy ([#407](https://github.com/QingWei-Li/docsify/issues/407)) ([0933445](https://github.com/QingWei-Li/docsify/commit/0933445))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **config:** Add 404 page options. ([#406](https://github.com/QingWei-Li/docsify/issues/406)) ([9b3b445](https://github.com/QingWei-Li/docsify/commit/9b3b445))
|
||||
|
||||
|
||||
|
||||
<a name="4.6.4"></a>
|
||||
## [4.6.4](https://github.com/QingWei-Li/docsify/compare/v4.6.3...v4.6.4) (2018-03-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **render:** Disable markdown parsing when the file is an HTML ([#403](https://github.com/QingWei-Li/docsify/issues/403)) ([278a75e](https://github.com/QingWei-Li/docsify/commit/278a75e))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **fetch:** Add fallback languages configuration. ([#402](https://github.com/QingWei-Li/docsify/issues/402)) ([ecc0e04](https://github.com/QingWei-Li/docsify/commit/ecc0e04))
|
||||
|
||||
|
||||
|
||||
<a name="4.6.3"></a>
|
||||
## [4.6.3](https://github.com/QingWei-Li/docsify/compare/v4.6.2...v4.6.3) (2018-02-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **hook:** beforeEach don\'t work, fixed [#393](https://github.com/QingWei-Li/docsify/issues/393) ([6a09059](https://github.com/QingWei-Li/docsify/commit/6a09059))
|
||||
|
||||
|
||||
|
||||
<a name="4.6.2"></a>
|
||||
## [4.6.2](https://github.com/QingWei-Li/docsify/compare/v4.6.1...v4.6.2) (2018-02-14)
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ Move to [awesome-docsify](https://github.com/QingWei-Li/awesome-docsify)
|
||||
|
||||
```bash
|
||||
npm run bootstrap && npm run dev
|
||||
open http://localhost:3000
|
||||
```
|
||||
|
||||
## Backers
|
||||
@@ -98,7 +97,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
||||
## Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
||||
<a href="graphs/contributors"><img src="https://opencollective.com/docsify/contributors.svg?width=890" /></a>
|
||||
<a href="https://github.com/QingWei-Li/docsify/graphs/contributors"><img src="https://opencollective.com/docsify/contributors.svg?width=890" /></a>
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
var serveStatic = require('serve-static')
|
||||
var http = require('http')
|
||||
var fs = require('fs')
|
||||
var Renderer = require('./packages/docsify-server-renderer/build.js')
|
||||
|
||||
var renderer = new Renderer({
|
||||
template: `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>docsify</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<link rel="stylesheet" href="/themes/vue.css" title="vue">
|
||||
</head>
|
||||
<body>
|
||||
<!--inject-app-->
|
||||
<!--inject-config-->
|
||||
<script src="/lib/docsify.js"></script>
|
||||
</body>
|
||||
</html>`,
|
||||
config: {
|
||||
name: 'docsify',
|
||||
repo: 'qingwei-li/docsify',
|
||||
basePath: 'https://docsify.js.org/',
|
||||
loadNavbar: true,
|
||||
loadSidebar: true,
|
||||
subMaxLevel: 3,
|
||||
auto2top: true,
|
||||
alias: {
|
||||
'/de-de/changelog': '/changelog',
|
||||
'/zh-cn/changelog': '/changelog',
|
||||
'/changelog':
|
||||
'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||
}
|
||||
},
|
||||
path: './'
|
||||
})
|
||||
|
||||
http
|
||||
.createServer(function (req, res) {
|
||||
serveStatic('.')(req, res, function () {
|
||||
// TEST SSR
|
||||
// renderer.renderToString(req.url)
|
||||
// .then(html => res.end(html))
|
||||
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end(fs.readFileSync('dev.html'))
|
||||
})
|
||||
})
|
||||
.listen(3000, '0.0.0.0')
|
||||
|
||||
console.log(`\nListening at http://0.0.0.0:3000\n`)
|
||||
@@ -1,50 +0,0 @@
|
||||
var fs = require('fs')
|
||||
var cssnano = require('cssnano').process
|
||||
var resolve = require('path').resolve
|
||||
var postcss = require('postcss')
|
||||
var isProd = process.argv[process.argv.length - 1] !== '--dev'
|
||||
|
||||
var processor = postcss([
|
||||
require('postcss-salad')({
|
||||
features: {
|
||||
precss: {
|
||||
properties: {
|
||||
preserve: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
])
|
||||
|
||||
var saveMin = function (file, content) {
|
||||
fs.writeFileSync(resolve(__dirname, '../lib/themes/', file), content)
|
||||
}
|
||||
var save = function (file, content) {
|
||||
fs.writeFileSync(resolve(__dirname, '../themes/', file), content)
|
||||
}
|
||||
var load = function (file) {
|
||||
return fs.readFileSync(resolve(__dirname, '../src/themes/', file)).toString()
|
||||
}
|
||||
var loadLib = function (file) {
|
||||
return fs.readFileSync(resolve(__dirname, '../themes/', file)).toString()
|
||||
}
|
||||
|
||||
var list = fs.readdirSync(resolve(__dirname, '../src/themes'))
|
||||
|
||||
list.forEach(function (file) {
|
||||
if (!/\.css$/.test(file)) return
|
||||
processor
|
||||
.process(load(file), { from: resolve(__dirname, '../src/themes/', file) })
|
||||
.then(function (result) {
|
||||
save(file, result.css)
|
||||
console.log('salad - ' + file)
|
||||
isProd &&
|
||||
cssnano(loadLib(file)).then(function (result) {
|
||||
saveMin(file, result.css)
|
||||
console.log('cssnao - ' + file)
|
||||
})
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.log(err)
|
||||
})
|
||||
})
|
||||
+86
-45
@@ -1,19 +1,19 @@
|
||||
var rollup = require('rollup')
|
||||
var buble = require('rollup-plugin-buble')
|
||||
var commonjs = require('rollup-plugin-commonjs')
|
||||
var nodeResolve = require('rollup-plugin-node-resolve')
|
||||
var string = require('rollup-plugin-string')
|
||||
var uglify = require('rollup-plugin-uglify')
|
||||
var replace = require('rollup-plugin-replace')
|
||||
var isProd = process.argv[process.argv.length - 1] !== '--dev'
|
||||
var version = process.env.VERSION || require('../package.json').version
|
||||
const rollup = require('rollup')
|
||||
const buble = require('rollup-plugin-buble')
|
||||
const commonjs = require('rollup-plugin-commonjs')
|
||||
const nodeResolve = require('rollup-plugin-node-resolve')
|
||||
const uglify = require('rollup-plugin-uglify')
|
||||
const replace = require('rollup-plugin-replace')
|
||||
const isProd = process.env.NODE_ENV === 'production'
|
||||
const version = process.env.VERSION || require('../package.json').version
|
||||
const chokidar = require('chokidar')
|
||||
const path = require('path')
|
||||
|
||||
var build = function (opts) {
|
||||
const build = function(opts) {
|
||||
rollup
|
||||
.rollup({
|
||||
input: 'src/' + opts.entry,
|
||||
input: opts.input,
|
||||
plugins: (opts.plugins || []).concat([
|
||||
string({ include: '**/*.css' }),
|
||||
buble(),
|
||||
commonjs(),
|
||||
nodeResolve(),
|
||||
@@ -23,8 +23,8 @@ var build = function (opts) {
|
||||
})
|
||||
])
|
||||
})
|
||||
.then(function (bundle) {
|
||||
var dest = 'lib/' + (opts.output || opts.entry)
|
||||
.then(function(bundle) {
|
||||
var dest = 'lib/' + (opts.output || opts.input)
|
||||
|
||||
console.log(dest)
|
||||
bundle.write({
|
||||
@@ -33,45 +33,86 @@ var build = function (opts) {
|
||||
strict: false
|
||||
})
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch(function(err) {
|
||||
console.error(err)
|
||||
})
|
||||
}
|
||||
|
||||
build({
|
||||
entry: 'core/index.js',
|
||||
output: 'docsify.js'
|
||||
})
|
||||
|
||||
var plugins = [
|
||||
{ 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' },
|
||||
{ name: 'disqus', entry: 'disqus.js' },
|
||||
{ name: 'gitalk', entry: 'gitalk.js' }
|
||||
]
|
||||
|
||||
plugins.forEach(item => {
|
||||
const buildCore = function() {
|
||||
build({
|
||||
entry: 'plugins/' + item.entry,
|
||||
output: 'plugins/' + item.name + '.js'
|
||||
input: 'src/core/index.js',
|
||||
output: 'docsify.js'
|
||||
})
|
||||
})
|
||||
|
||||
if (isProd) {
|
||||
build({
|
||||
entry: 'core/index.js',
|
||||
output: 'docsify.min.js',
|
||||
plugins: [uglify()]
|
||||
})
|
||||
plugins.forEach(item => {
|
||||
if (isProd) {
|
||||
build({
|
||||
entry: 'plugins/' + item.entry,
|
||||
output: 'plugins/' + item.name + '.min.js',
|
||||
input: 'src/core/index.js',
|
||||
output: 'docsify.min.js',
|
||||
plugins: [uglify()]
|
||||
})
|
||||
}
|
||||
}
|
||||
const buildAllPlugin = function() {
|
||||
var plugins = [
|
||||
{name: 'search', input: 'search/index.js'},
|
||||
{name: 'ga', input: 'ga.js'},
|
||||
{name: 'emoji', input: 'emoji.js'},
|
||||
{name: 'external-script', input: 'external-script.js'},
|
||||
{name: 'front-matter', input: 'front-matter/index.js'},
|
||||
{name: 'zoom-image', input: 'zoom-image.js'},
|
||||
{name: 'disqus', input: 'disqus.js'},
|
||||
{name: 'gitalk', input: 'gitalk.js'}
|
||||
]
|
||||
|
||||
plugins.forEach(item => {
|
||||
build({
|
||||
input: 'src/plugins/' + item.input,
|
||||
output: 'plugins/' + item.name + '.js'
|
||||
})
|
||||
})
|
||||
|
||||
if (isProd) {
|
||||
plugins.forEach(item => {
|
||||
build({
|
||||
input: 'src/plugins/' + item.input,
|
||||
output: 'plugins/' + item.name + '.min.js',
|
||||
plugins: [uglify()]
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!isProd) {
|
||||
chokidar
|
||||
.watch(['src/core', 'src/plugins'], {
|
||||
atomic: true,
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: 1000,
|
||||
pollInterval: 100
|
||||
}
|
||||
})
|
||||
.on('change', p => {
|
||||
console.log('[watch] ', p)
|
||||
const dirs = p.split(path.sep)
|
||||
if (dirs[1] === 'core') {
|
||||
buildCore()
|
||||
} else if (dirs[2]) {
|
||||
const name = path.basename(dirs[2], '.js')
|
||||
const input = `src/plugins/${name}${
|
||||
/\.js/.test(dirs[2]) ? '' : '/index'
|
||||
}.js`
|
||||
|
||||
build({
|
||||
input,
|
||||
output: 'plugins/' + name + '.js'
|
||||
})
|
||||
}
|
||||
})
|
||||
.on('ready', () => {
|
||||
console.log('[start]')
|
||||
buildCore()
|
||||
buildAllPlugin()
|
||||
})
|
||||
} else {
|
||||
buildCore()
|
||||
buildAllPlugin()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
const cssnano = require('cssnano').process
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
files = fs.readdirSync(path.resolve('lib/themes'))
|
||||
|
||||
files.forEach(file => {
|
||||
file = path.resolve('lib/themes', file)
|
||||
cssnano(fs.readFileSync(file)).then(result => {
|
||||
fs.writeFileSync(file, result.css)
|
||||
})
|
||||
})
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||

|
||||
|
||||
# docsify <small>4.6.2</small>
|
||||
# docsify <small>4.7.0</small>
|
||||
|
||||
> A magical documentation site generator.
|
||||
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
- [:cn: 中文](/zh-cn/)
|
||||
- [:de: Deutsch](/de-de/)
|
||||
- [:uk: English](/)
|
||||
- [:es: Spanish](https://docsify-es.js.org)
|
||||
- [:ru: Russian](https://docsify-ru.js.org)
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
* [Vue compatibility](vue.md)
|
||||
* [CDN](cdn.md)
|
||||
* [Offline Mode(PWA)](pwa.md)
|
||||
* [Server-client renderer(SSR)](ssr.md)
|
||||
* [Server-Side Rendering(SSR)](ssr.md)
|
||||
* [Embed Files <sup style="color:red">(new)<sup>](embed-files.md)
|
||||
|
||||
* [Awesome docsify](awesome.md)
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ Recommended: [unpkg](//unpkg.com), which will reflect the latest version as soon
|
||||
<script src="//unpkg.com/docsify/lib/docsify.js"></script>
|
||||
```
|
||||
|
||||
Alternatively, use [compressed files](#compressed-files).
|
||||
Alternatively, use [compressed files](#compressed-file).
|
||||
|
||||
## Specific version
|
||||
|
||||
|
||||
+102
-39
@@ -14,8 +14,8 @@ You can configure the `window.$docsify`.
|
||||
|
||||
## el
|
||||
|
||||
* Type: `String`
|
||||
* Default: `#app`
|
||||
- Type: `String`
|
||||
- Default: `#app`
|
||||
|
||||
The DOM element to be mounted on initialization. It can be a CSS selector string or an actual HTMLElement.
|
||||
|
||||
@@ -27,8 +27,8 @@ window.$docsify = {
|
||||
|
||||
## repo
|
||||
|
||||
* Type: `String`
|
||||
* Default: `null`
|
||||
- Type: `String`
|
||||
- Default: `null`
|
||||
|
||||
Configure the repository url or a string of `username/repo` can add the [GitHub Corner](http://tholman.com/github-corners/) widget in the top right corner of the site.
|
||||
|
||||
@@ -42,8 +42,8 @@ window.$docsify = {
|
||||
|
||||
## maxLevel
|
||||
|
||||
* Type: `Number`
|
||||
* Default: `6`
|
||||
- Type: `Number`
|
||||
- Default: `6`
|
||||
|
||||
Maximum Table of content level.
|
||||
|
||||
@@ -55,8 +55,8 @@ window.$docsify = {
|
||||
|
||||
## loadNavbar
|
||||
|
||||
* Type: `Boolean|String`
|
||||
* Default: `false`
|
||||
- Type: `Boolean|String`
|
||||
- Default: `false`
|
||||
|
||||
Loads navbar from the Markdown file `_navbar.md` if **true**, or else from the path specified.
|
||||
|
||||
@@ -72,8 +72,8 @@ window.$docsify = {
|
||||
|
||||
## loadSidebar
|
||||
|
||||
* Type: `Boolean|String`
|
||||
* Default: `false`
|
||||
- Type: `Boolean|String`
|
||||
- Default: `false`
|
||||
|
||||
Loads sidebar from the Markdown file `_sidebar.md` if **true**, or else from the path specified.
|
||||
|
||||
@@ -89,8 +89,8 @@ window.$docsify = {
|
||||
|
||||
## subMaxLevel
|
||||
|
||||
* Type: `Number`
|
||||
* Default: `0`
|
||||
- Type: `Number`
|
||||
- Default: `0`
|
||||
|
||||
Add table of contents (TOC) in custom sidebar.
|
||||
|
||||
@@ -102,8 +102,8 @@ window.$docsify = {
|
||||
|
||||
## auto2top
|
||||
|
||||
* Type: `Boolean`
|
||||
* Default: `false`
|
||||
- Type: `Boolean`
|
||||
- Default: `false`
|
||||
|
||||
Scrolls to the top of the screen when the route is changed.
|
||||
|
||||
@@ -115,8 +115,8 @@ window.$docsify = {
|
||||
|
||||
## homepage
|
||||
|
||||
* Type: `String`
|
||||
* Default: `README.md`
|
||||
- Type: `String`
|
||||
- Default: `README.md`
|
||||
|
||||
`README.md` in your docs folder will be treated as homepage for your website, but sometimes you may need to serve another file as your homepage.
|
||||
|
||||
@@ -133,7 +133,7 @@ window.$docsify = {
|
||||
|
||||
## basePath
|
||||
|
||||
* Type: `String`
|
||||
- Type: `String`
|
||||
|
||||
Base path of the website. You can set it to another directory or another domain name.
|
||||
|
||||
@@ -152,8 +152,8 @@ window.$docsify = {
|
||||
|
||||
## coverpage
|
||||
|
||||
* Type: `Boolean|String|String[]|Object`
|
||||
* Default: `false`
|
||||
- Type: `Boolean|String|String[]|Object`
|
||||
- Default: `false`
|
||||
|
||||
Activate the [cover feature](cover.md). If true, it will load from `_coverpage.md`.
|
||||
|
||||
@@ -175,9 +175,21 @@ window.$docsify = {
|
||||
};
|
||||
```
|
||||
|
||||
## logo
|
||||
|
||||
- Type: `String`
|
||||
|
||||
Website logo as it appears in the sidebar, you can resize by CSS.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
logo: '/_media/icon.svg'
|
||||
};
|
||||
```
|
||||
|
||||
## name
|
||||
|
||||
* Type: `String`
|
||||
- Type: `String`
|
||||
|
||||
Website name as it appears in the sidebar.
|
||||
|
||||
@@ -189,8 +201,8 @@ window.$docsify = {
|
||||
|
||||
## nameLink
|
||||
|
||||
* Type: `String`
|
||||
* Default: `window.location.pathname`
|
||||
- Type: `String`
|
||||
- Default: `window.location.pathname`
|
||||
|
||||
The name of the link.
|
||||
|
||||
@@ -208,7 +220,7 @@ window.$docsify = {
|
||||
|
||||
## markdown
|
||||
|
||||
* Type: `Function`
|
||||
- Type: `Function`
|
||||
|
||||
See [Markdown configuration](markdown.md).
|
||||
|
||||
@@ -234,7 +246,7 @@ window.$docsify = {
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -246,7 +258,7 @@ window.$docsify = {
|
||||
|
||||
## alias
|
||||
|
||||
* Type: `Object`
|
||||
- Type: `Object`
|
||||
|
||||
Set the route alias. You can freely manage routing rules. Supports RegExp.
|
||||
|
||||
@@ -264,7 +276,7 @@ window.$docsify = {
|
||||
|
||||
## 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).
|
||||
|
||||
@@ -277,7 +289,7 @@ window.$docsify = {
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -299,7 +311,7 @@ Note that if you are running an external script, e.g. an embedded jsfiddle demo,
|
||||
|
||||
## noEmoji
|
||||
|
||||
* type: `Boolean`
|
||||
- type: `Boolean`
|
||||
|
||||
Disabled emoji parse.
|
||||
|
||||
@@ -311,7 +323,7 @@ window.$docsify = {
|
||||
|
||||
## mergeNavbar
|
||||
|
||||
* type: `Boolean`
|
||||
- type: `Boolean`
|
||||
|
||||
Navbar will be merged with the sidebar on smaller screens.
|
||||
|
||||
@@ -323,7 +335,7 @@ window.$docsify = {
|
||||
|
||||
## 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`.
|
||||
See https://github.com/lukeed/tinydate#patterns
|
||||
@@ -342,8 +354,8 @@ window.$docsify = {
|
||||
|
||||
## externalLinkTarget
|
||||
|
||||
* type: `String`
|
||||
* default: `_blank`
|
||||
- type: `String`
|
||||
- default: `_blank`
|
||||
|
||||
Target to open external links. Default `'_blank'` (new window/tab)
|
||||
|
||||
@@ -355,8 +367,8 @@ window.$docsify = {
|
||||
|
||||
## routerMode
|
||||
|
||||
* type: `String`
|
||||
* default: `history`
|
||||
- type: `String`
|
||||
- default: `hash`
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -366,7 +378,7 @@ window.$docsify = {
|
||||
|
||||
## 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)
|
||||
|
||||
@@ -378,9 +390,9 @@ window.$docsify = {
|
||||
|
||||
## onlyCover
|
||||
|
||||
* type: `Boolean`
|
||||
- type: `Boolean`
|
||||
|
||||
Only coverpage is loaded when When visiting the home page.
|
||||
Only coverpage is loaded when visiting the home page.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -390,7 +402,7 @@ window.$docsify = {
|
||||
|
||||
## requestHeaders
|
||||
|
||||
* type: `Object`
|
||||
- type: `Object`
|
||||
|
||||
Set the request resource headers.
|
||||
|
||||
@@ -404,7 +416,7 @@ window.$docsify = {
|
||||
|
||||
## ext
|
||||
|
||||
* type: `String`
|
||||
- type: `String`
|
||||
|
||||
Request file extension.
|
||||
|
||||
@@ -413,3 +425,54 @@ window.$docsify = {
|
||||
ext: '.md'
|
||||
};
|
||||
```
|
||||
|
||||
## fallbackLanguages
|
||||
|
||||
- type: `Array<string>`
|
||||
|
||||
List of languages that will fallback to the default language when a page is request and didn't exists for the given local.
|
||||
|
||||
Example:
|
||||
|
||||
- try to fetch the page of `/de/overview`. If this page exists, it'll be displayed
|
||||
- then try to fetch the default page `/overview` (depending on the default language). If this page exists, it'll be displayed
|
||||
- then display 404 page.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
fallbackLanguages: ['fr', 'de']
|
||||
};
|
||||
```
|
||||
|
||||
## notFoundPage
|
||||
|
||||
- type: `Boolean` | `String` | `Object`
|
||||
|
||||
Load the `_404.md` file:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: true
|
||||
};
|
||||
```
|
||||
|
||||
Load the customised path of the 404 page:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: 'my404.md'
|
||||
};
|
||||
```
|
||||
|
||||
Load the right 404 page according to the localisation:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: {
|
||||
'/': '_404.md',
|
||||
'/de': 'de/_404.md'
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
> Note: The options with fallbackLanguages didn't work with the `notFoundPage` options.
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ The background color is generated randomly by default. You can customize the bac
|
||||
|
||||
## Coverpage as homepage
|
||||
|
||||
Normal, the coverpage and the homepage appear at the same time. Of course, you can also separate the coverpage by [onlyCover option](configuration.md#onlycover).
|
||||
Normally, the coverpage and the homepage appear at the same time. Of course, you can also separate the coverpage by [onlyCover option](configuration.md#onlycover).
|
||||
|
||||
## Multiple covers
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* [Vue Kompatibilität](de-de/vue.md)
|
||||
* [CDN](de-de/cdn.md)
|
||||
* [Offline Modus (PWA)](de-de/pwa.md)
|
||||
* [Server-client renderer (SSR)](de-de/ssr.md)
|
||||
* [Server-Side Rendering (SSR)](de-de/ssr.md)
|
||||
* [Embed Files <sup style="color:red">(new)<sup>](de-de/embed-files.md)
|
||||
|
||||
* [Awesome docsify](de-de/awesome.md)
|
||||
|
||||
+100
-37
@@ -14,8 +14,8 @@ You can configure the `window.$docsify`.
|
||||
|
||||
## el
|
||||
|
||||
* Typ: `String`
|
||||
* Standard: `#app`
|
||||
- Typ: `String`
|
||||
- Standard: `#app`
|
||||
|
||||
Das DOM Element kann bei der Initialisierung gesetzt werden. Es kann ein CSS selector string oder ein richtiges HTMLElement sein.
|
||||
|
||||
@@ -27,8 +27,8 @@ window.$docsify = {
|
||||
|
||||
## repo
|
||||
|
||||
* Typ: `String`
|
||||
* Standard: `null`
|
||||
- Typ: `String`
|
||||
- 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.
|
||||
|
||||
@@ -42,8 +42,8 @@ window.$docsify = {
|
||||
|
||||
## maxLevel
|
||||
|
||||
* Typ: `Number`
|
||||
* Standard: `6`
|
||||
- Typ: `Number`
|
||||
- Standard: `6`
|
||||
|
||||
Maximale Anzahl der Inhaltsübersichtebenen.
|
||||
|
||||
@@ -55,8 +55,8 @@ window.$docsify = {
|
||||
|
||||
## loadNavbar
|
||||
|
||||
* Typ: `Boolean|String`
|
||||
* Standard: `false`
|
||||
- Typ: `Boolean|String`
|
||||
- Standard: `false`
|
||||
|
||||
Lädt die Navigationsleiste von der Markdown Datei `_navbar.md` falls **true**, oder vom gewählten Pfad.
|
||||
|
||||
@@ -72,8 +72,8 @@ window.$docsify = {
|
||||
|
||||
## loadSidebar
|
||||
|
||||
* Typ: `Boolean|String`
|
||||
* Standard: `false`
|
||||
- Typ: `Boolean|String`
|
||||
- Standard: `false`
|
||||
|
||||
Lädt das seitliche Inhaltsverzeichnis von der Markdown Datei `_sidebar.md` falls **true**, oder vom gewählten Pfad.
|
||||
|
||||
@@ -89,8 +89,8 @@ window.$docsify = {
|
||||
|
||||
## subMaxLevel
|
||||
|
||||
* Typ: `Number`
|
||||
* Standard: `0`
|
||||
- Typ: `Number`
|
||||
- Standard: `0`
|
||||
|
||||
Wähle die maximale Anzahl der Unterpunkte pro Datei in der Inhaltsübersicht.
|
||||
|
||||
@@ -102,8 +102,8 @@ window.$docsify = {
|
||||
|
||||
## auto2top
|
||||
|
||||
* Typ: `Boolean`
|
||||
* Standard: `false`
|
||||
- Typ: `Boolean`
|
||||
- Standard: `false`
|
||||
|
||||
Scrolle zum Anfang der Seite, wenn die Route gewechselt wird.
|
||||
|
||||
@@ -115,8 +115,8 @@ window.$docsify = {
|
||||
|
||||
## homepage
|
||||
|
||||
* Typ: `String`
|
||||
* Standard: `README.md`
|
||||
- Typ: `String`
|
||||
- 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.
|
||||
|
||||
@@ -133,7 +133,7 @@ window.$docsify = {
|
||||
|
||||
## basePath
|
||||
|
||||
* Typ: `String`
|
||||
- Typ: `String`
|
||||
|
||||
Der Basispfad der Webseite. Du kannst einen anderen Ordner wählen, oder eine andere Domain.
|
||||
|
||||
@@ -152,8 +152,8 @@ window.$docsify = {
|
||||
|
||||
## coverpage
|
||||
|
||||
* Typ: `Boolean|String`
|
||||
* Standard: `false`
|
||||
- Typ: `Boolean|String`
|
||||
- Standard: `false`
|
||||
|
||||
Aktiviere das [Titelseitenfeature](de-de/cover.md). Falls `true`, wird sie von `_coverpage.md` geladen.
|
||||
|
||||
@@ -175,9 +175,21 @@ window.$docsify = {
|
||||
};
|
||||
```
|
||||
|
||||
## logo
|
||||
|
||||
- Type: `String`
|
||||
|
||||
Website logo as it appears in the sidebar, you can resize by CSS.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
logo: '/_media/icon.svg'
|
||||
};
|
||||
```
|
||||
|
||||
## name
|
||||
|
||||
* Typ: `String`
|
||||
- Typ: `String`
|
||||
|
||||
Webseitenname, wie er in der Inhaltsübersicht in der Seitenleiste angezeigt wird.
|
||||
|
||||
@@ -189,8 +201,8 @@ window.$docsify = {
|
||||
|
||||
## nameLink
|
||||
|
||||
* Typ: `String`
|
||||
* Standard: `window.location.pathname`
|
||||
- Typ: `String`
|
||||
- Standard: `window.location.pathname`
|
||||
|
||||
Der Name der Links.
|
||||
|
||||
@@ -208,7 +220,7 @@ window.$docsify = {
|
||||
|
||||
## markdown
|
||||
|
||||
* Typ: `Function`
|
||||
- Typ: `Function`
|
||||
|
||||
Siehe [Markdown Konfiguration](de-de/markdown.md).
|
||||
|
||||
@@ -234,7 +246,7 @@ window.$docsify = {
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -246,7 +258,7 @@ window.$docsify = {
|
||||
|
||||
## alias
|
||||
|
||||
* Typ: `Object`
|
||||
- Typ: `Object`
|
||||
|
||||
Verwende alternative Routen. Du kannst sie ungehindert anpassen. Supports RegExp.
|
||||
|
||||
@@ -264,7 +276,7 @@ window.$docsify = {
|
||||
|
||||
## 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).
|
||||
|
||||
@@ -277,7 +289,7 @@ window.$docsify = {
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -299,7 +311,7 @@ window.$docsify = {
|
||||
|
||||
## noEmoji
|
||||
|
||||
* type: `Boolean`
|
||||
- type: `Boolean`
|
||||
|
||||
Verhindere die Umwandlung in Emojis:
|
||||
|
||||
@@ -311,7 +323,7 @@ window.$docsify = {
|
||||
|
||||
## mergeNavbar
|
||||
|
||||
* type: `Boolean`
|
||||
- type: `Boolean`
|
||||
|
||||
Navbar will be merged with the sidebar on smaller screens.
|
||||
|
||||
@@ -323,7 +335,7 @@ window.$docsify = {
|
||||
|
||||
## 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`.
|
||||
See https://github.com/lukeed/tinydate#patterns
|
||||
@@ -342,8 +354,8 @@ window.$docsify = {
|
||||
|
||||
## externalLinkTarget
|
||||
|
||||
* type: `String`
|
||||
* default: `_blank`
|
||||
- type: `String`
|
||||
- default: `_blank`
|
||||
|
||||
Currently it defaults to \_blank, would be nice if configurable:
|
||||
|
||||
@@ -355,8 +367,8 @@ window.$docsify = {
|
||||
|
||||
## routerMode
|
||||
|
||||
* type: `String`
|
||||
* default: `history`
|
||||
- type: `String`
|
||||
- default: `history`
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -366,7 +378,7 @@ window.$docsify = {
|
||||
|
||||
## 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)
|
||||
|
||||
@@ -378,7 +390,7 @@ window.$docsify = {
|
||||
|
||||
## requestHeaders
|
||||
|
||||
* type: `Object`
|
||||
- type: `Object`
|
||||
|
||||
Set the request resource headers.
|
||||
|
||||
@@ -392,7 +404,7 @@ window.$docsify = {
|
||||
|
||||
## ext
|
||||
|
||||
* type: `String`
|
||||
- type: `String`
|
||||
|
||||
Request file extension.
|
||||
|
||||
@@ -401,3 +413,54 @@ window.$docsify = {
|
||||
ext: '.md'
|
||||
};
|
||||
```
|
||||
|
||||
## fallbackLanguages
|
||||
|
||||
- type: `Array<string>`
|
||||
|
||||
List of languages that will fallback to the default language when a page is request and didn't exists for the given local.
|
||||
|
||||
Example:
|
||||
|
||||
- try to fetch the page of `/de/overview`. If this page exists, it'll be displayed
|
||||
- then try to fetch the default page `/overview` (depending on the default language). If this page exists, it'll be displayed
|
||||
- then display 404 page.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
fallbackLanguages: ['fr', 'de']
|
||||
};
|
||||
```
|
||||
|
||||
## notFoundPage
|
||||
|
||||
- type: `Boolean` | `String` | `Object`
|
||||
|
||||
Load the `_404.md` file:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: true
|
||||
};
|
||||
```
|
||||
|
||||
Load the customised path of the 404 page:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: 'my404.md'
|
||||
};
|
||||
```
|
||||
|
||||
Load the right 404 page according to the localisation:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: {
|
||||
'/': '_404.md',
|
||||
'/de': 'de/_404.md'
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
> Note: The options with fallbackLanguages didn't work with the `notFoundPage` options.
|
||||
|
||||
@@ -68,7 +68,7 @@ Du kannst untergeordnete Listen erstellen, indem du untergeordnete Punkte einem
|
||||
|
||||
wird also wie folgt aussehen
|
||||
|
||||

|
||||

|
||||
|
||||
## Angepasste Navigationsleisten in Verbindung mit dem emoji Erweiterung
|
||||
|
||||
|
||||
+19
-7
@@ -6,24 +6,23 @@
|
||||
|
||||
Du kannst folgende drei Orte verwenden, um die Dokumentation für dein Github repository zu verwalten:
|
||||
|
||||
* `docs/` Ordner
|
||||
* master branch
|
||||
* gh-pages branch
|
||||
- `docs/` Ordner
|
||||
- master branch
|
||||
- gh-pages branch
|
||||
|
||||
Es wird empfohlen, deine Dateien im `./docs` Unterordner im `master` branch deines repository zu speichern. Wechsle dann zu den Einstellungen deines repository und wähle `master branch /docs folder` als deine Github Pages Quelle.
|
||||
|
||||

|
||||

|
||||
|
||||
!> Du kannst die Dateien auch im Hauptverzeichnis speichern und dann `master branch` in den Einstellungen auswählen.
|
||||
|
||||
|
||||
## GitLab Pages
|
||||
|
||||
If you are deploying your master branch, include `.gitlab-ci.yml` with the following script:
|
||||
|
||||
?> The `.public` workaround is so `cp` doesn't also copy `public/` to itself in an infinite loop.
|
||||
|
||||
``` YAML
|
||||
```YAML
|
||||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
@@ -39,7 +38,6 @@ pages:
|
||||
|
||||
!> You can replace script with `- cp -r docs/. public`, if `./docs` is your Docsify subfolder.
|
||||
|
||||
|
||||
## VPS
|
||||
|
||||
Verwende folgende nginx config.
|
||||
@@ -55,3 +53,17 @@ server {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Netlify
|
||||
|
||||
1. Login to your [Netlify](https://www.netlify.com/) account.
|
||||
2. In the [dashboard](https://app.netlify.com/) page, click **New site from Git**.
|
||||
3. Choose a repository where you store your docs, leave the **Build Command** area blank, fill in the Publish directory area with the directory of your `index.html`, for example it should be docs if you populated it at `docs/index.html`.
|
||||
|
||||
### HTML5 router
|
||||
|
||||
When using the HTML5 router, you need to set up redirect rules that redirect all requests to your `index.html`, it's pretty simple when you're using Netlify, populate a `\redirects` file in the docs directory and you're all set:
|
||||
|
||||
```sh
|
||||
/* /index.html 200
|
||||
```
|
||||
|
||||
@@ -6,14 +6,14 @@ You can embed these files as video, audio, iframes, or code blocks, and even Mar
|
||||
For example, here embedded a Markdown file. You only need to do this:
|
||||
|
||||
```markdown
|
||||
[filename](_media/example.md ':include')
|
||||
[filename](../_media/example.md ':include')
|
||||
```
|
||||
|
||||
Then the content of `example.md` will be displayed directly here
|
||||
|
||||
[filename](_media/example.md ':include')
|
||||
[filename](../_media/example.md ':include')
|
||||
|
||||
You can check the original content for [example.md](_media/example.md ':ignore').
|
||||
You can check the original content for [example.md](../_media/example.md ':ignore').
|
||||
|
||||
Normally, this will compiled into a link, but in docsify, if you add `:include` it will be embedded.
|
||||
|
||||
@@ -32,12 +32,12 @@ This is a supported embedding type:
|
||||
Of course, you can force the specified. For example, you want to Markdown file as code block embedded.
|
||||
|
||||
```markdown
|
||||
[filename](_media/example.md ':include :type=code')
|
||||
[filename](../_media/example.md ':include :type=code')
|
||||
```
|
||||
|
||||
You will get it
|
||||
|
||||
[filename](_media/example.md ':include :type=code')
|
||||
[filename](../_media/example.md ':include :type=code')
|
||||
|
||||
## Tag attribute
|
||||
|
||||
@@ -56,11 +56,11 @@ Did you see it? You only need to write directly. You can check [MDN](https://dev
|
||||
Embedding any type of source code file, you can specify the highlighted language or automatically identify.
|
||||
|
||||
```markdown
|
||||
[](_media/example.html ':include :type=code text')
|
||||
[](../_media/example.html ':include :type=code text')
|
||||
```
|
||||
|
||||
⬇️
|
||||
|
||||
[](_media/example.html ':include :type=code text')
|
||||
[](../_media/example.html ':include :type=code text')
|
||||
|
||||
?> How to set highlight? You can see [here](language-highlight.md).
|
||||
|
||||
+22
-12
@@ -60,17 +60,27 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
|
||||
## Github Task Lists
|
||||
|
||||
```md
|
||||
* [ ] foo
|
||||
* bar
|
||||
* [x] baz
|
||||
* [] bam <~ not working
|
||||
* [ ] bim
|
||||
* [ ] lim
|
||||
- [ ] foo
|
||||
- bar
|
||||
- [x] baz
|
||||
- [] bam <~ not working
|
||||
- [ ] bim
|
||||
- [ ] lim
|
||||
```
|
||||
|
||||
* [ ] foo
|
||||
* bar
|
||||
* [x] baz
|
||||
* [] bam <~ not working
|
||||
* [ ] bim
|
||||
* [ ] lim
|
||||
- [ ] foo
|
||||
- bar
|
||||
- [x] baz
|
||||
- [] bam <~ not working
|
||||
- [ ] bim
|
||||
- [ ] lim
|
||||
|
||||
## Image resizing
|
||||
|
||||
```md
|
||||

|
||||

|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Markdown Einstellungen
|
||||
|
||||
**docsify** verwendet [marked](https://github.com/chjj/marked), um Markdown umzuwandeln. Du kannst einstellen, wie es deine Markdown Seiten in HTML umwandelt, indem du `renderer` konfigurierst:
|
||||
**docsify** verwendet [marked](https://github.com/markedjs/marked), um Markdown umzuwandeln. Du kannst einstellen, wie es deine Markdown Seiten in HTML umwandelt, indem du `renderer` konfigurierst:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -15,7 +15,7 @@ window.$docsify = {
|
||||
}
|
||||
```
|
||||
|
||||
?> Für mögliche Einstellungen, siehe [marked Dokumentation](https://github.com/chjj/marked#options-1)
|
||||
?> Für mögliche Einstellungen, siehe [marked Dokumentation](https://github.com/markedjs/marked#options-1)
|
||||
|
||||
Du kannst die Regeln auch beliebig anpassen.
|
||||
|
||||
|
||||
+3
-23
@@ -4,7 +4,6 @@
|
||||
|
||||
Als Standardeinstellung werden Hyperlinks auf der aktuellen Seite erkannt und der Inhalt in `localStorage` gespeichert. Du kannst den Pfad zu den Dateien auch anpassen:
|
||||
|
||||
|
||||
```html
|
||||
<script>
|
||||
window.$docsify = {
|
||||
@@ -67,12 +66,6 @@ Konfiguration über `data-ga`:
|
||||
<script src="//unpkg.com/docsify/lib/plugins/ga.min.js"></script>
|
||||
```
|
||||
|
||||
## front matter
|
||||
|
||||
```html
|
||||
<script src="//unpkg.com/docsify/lib/plugins/front-matter.min.js"></script>
|
||||
```
|
||||
|
||||
## emoji
|
||||
|
||||
Als Standardeinstellung werden emojis umgewandelt. Als Beispiel wird `:100:` umgewandelt in :100:. Aber das ist nicht genau, das es keine passende Nicht-emoji Zeichenfolge gibt. Solltest du emojis richtig umwandeln wollen, musst du diese Erweiterung verwenden.
|
||||
@@ -111,7 +104,6 @@ When readers expand the demo box, the source code and description are shown ther
|
||||
|
||||
[Vue](https://njleonzhang.github.io/docsify-demo-box-vue/) and [React](https://njleonzhang.github.io/docsify-demo-box-react/) are both supported.
|
||||
|
||||
|
||||
## Edit on github
|
||||
|
||||
Add `Edit on github` button on every pages. Provided by [@njleonzhang](https://github.com/njleonzhang), check [document](https://github.com/njleonzhang/docsify-edit-on-github)
|
||||
@@ -121,22 +113,11 @@ Add `Edit on github` button on every pages. Provided by [@njleonzhang](https://g
|
||||
Add a simple `Click to copy` button to all preformatted code blocks to effortlessly allow users to copy example code from your docs. Provided by [@jperasmus](https://github.com/jperasmus)
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify-copy-code/styles.css">
|
||||
<script src="//unpkg.com/docsify-copy-code/index.js"></script>
|
||||
```
|
||||
|
||||
```javascript
|
||||
window.$docsify = {
|
||||
plugins: [
|
||||
window.DocsifyCopyCodePlugin.init()
|
||||
]
|
||||
}
|
||||
<script src="//unpkg.com/docsify-copy-code"></script>
|
||||
```
|
||||
|
||||
See [here](https://github.com/jperasmus/docsify-copy-code/blob/master/README.md) for more details.
|
||||
|
||||
|
||||
|
||||
## Disqus
|
||||
|
||||
Disqus comments. https://disqus.com/
|
||||
@@ -150,10 +131,9 @@ Disqus comments. https://disqus.com/
|
||||
<script src="//unpkg.com/docsify/lib/plugins/disqus.min.js"></script>
|
||||
```
|
||||
|
||||
|
||||
## Gitalk
|
||||
|
||||
[Gitalk](https://github.com/gitalk/gitalk) is a modern comment component based on Github Issue and Preact.
|
||||
[Gitalk](https://github.com/gitalk/gitalk) is a modern comment component based on Github Issue and Preact.
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//unpkg.com/gitalk/dist/gitalk.css">
|
||||
@@ -173,7 +153,7 @@ Disqus comments. https://disqus.com/
|
||||
</script>
|
||||
```
|
||||
|
||||
## Navigation
|
||||
## Pagination
|
||||
|
||||
Pagination for docsify. By [@imyelo](https://github.com/imyelo)
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Server client renderer
|
||||
# Server-Side Rendering
|
||||
|
||||
See https://docsify.now.sh
|
||||
|
||||
|
||||
@@ -54,3 +54,9 @@ Solltest du weitere Themes erstellen, kannst du sie gerne der Allgemeinheit mit
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
## Other themes
|
||||
|
||||
- [docsify-themeable](https://jhildenbiddle.github.io/docsify-themeable/#/) A delightfully simple theme system for docsify.
|
||||
|
||||
+21
-10
@@ -6,9 +6,9 @@ Similar to [GitBook](https://www.gitbook.com), you can deploy files to GitHub Pa
|
||||
|
||||
There're three places to populate your docs for your Github repository:
|
||||
|
||||
* `docs/` folder
|
||||
* master branch
|
||||
* gh-pages branch
|
||||
- `docs/` folder
|
||||
- master branch
|
||||
- gh-pages branch
|
||||
|
||||
It is recommended that you save your files to the `./docs` subfolder of the `master` branch of your repository. Then select `master branch /docs folder` as your Github Pages source in your repositories' settings page.
|
||||
|
||||
@@ -23,7 +23,7 @@ If you are deploying your master branch, include `.gitlab-ci.yml` with the follo
|
||||
|
||||
?> The `.public` workaround is so `cp` doesn't also copy `public/` to itself in an infinite loop.
|
||||
|
||||
``` YAML
|
||||
```YAML
|
||||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
@@ -41,20 +41,17 @@ pages:
|
||||
|
||||
## Firebase Hosting
|
||||
|
||||
!> You'll need to install the Firebase CLI using `npm i -g firebase-tools` after signing into the [Firebase Console](https://console.firebase.google.com) using a Google Account.
|
||||
!> You'll need to install the Firebase CLI using `npm i -g firebase-tools` after signing into the [Firebase Console](https://console.firebase.google.com) using a Google Account.
|
||||
|
||||
Using Terminal determine and navigate to the directory for your Firebase Project - this could be `~/Projects/Docs` etc. From there, run `firebase init`, choosing `Hosting` from the menu (use **space** to select, **arrow keys** to change options and **enter** to confirm). Follow the setup instructions.
|
||||
|
||||
You should have your `firebase.json` file looking similar to this (I changed the deployment directory from `public` to `site`):
|
||||
|
||||
```json
|
||||
{
|
||||
"hosting": {
|
||||
"public": "site",
|
||||
"ignore": [
|
||||
"firebase.json",
|
||||
"**/.*",
|
||||
"**/node_modules/**"
|
||||
]
|
||||
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -76,3 +73,17 @@ server {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Netlify
|
||||
|
||||
1. Login to your [Netlify](https://www.netlify.com/) account.
|
||||
2. In the [dashboard](https://app.netlify.com/) page, click **New site from Git**.
|
||||
3. Choose a repository where you store your docs, leave the **Build Command** area blank, fill in the Publish directory area with the directory of your `index.html`, for example it should be docs if you populated it at `docs/index.html`.
|
||||
|
||||
### HTML5 router
|
||||
|
||||
When using the HTML5 router, you need to set up redirect rules that redirect all requests to your `index.html`, it's pretty simple when you're using Netlify, populate a `\redirects` file in the docs directory and you're all set:
|
||||
|
||||
```sh
|
||||
/* /index.html 200
|
||||
```
|
||||
|
||||
+22
-12
@@ -66,17 +66,27 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
|
||||
## Github Task Lists
|
||||
|
||||
```md
|
||||
* [ ] foo
|
||||
* bar
|
||||
* [x] baz
|
||||
* [] bam <~ not working
|
||||
* [ ] bim
|
||||
* [ ] lim
|
||||
- [ ] foo
|
||||
- bar
|
||||
- [x] baz
|
||||
- [] bam <~ not working
|
||||
- [ ] bim
|
||||
- [ ] lim
|
||||
```
|
||||
|
||||
* [ ] foo
|
||||
* bar
|
||||
* [x] baz
|
||||
* [] bam <~ not working
|
||||
* [ ] bim
|
||||
* [ ] lim
|
||||
- [ ] foo
|
||||
- bar
|
||||
- [x] baz
|
||||
- [] bam <~ not working
|
||||
- [ ] bim
|
||||
- [ ] lim
|
||||
|
||||
## Image resizing
|
||||
|
||||
```md
|
||||

|
||||

|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
+5
-3
@@ -14,6 +14,7 @@
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/dark.css" title="dark" disabled>
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/buble.css" title="buble" disabled>
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/pure.css" title="pure" disabled>
|
||||
<script src="//unpkg.com/docsify-plugin-codefund@1.0.3/index.js"></script>
|
||||
<style>
|
||||
nav.app-nav li ul {
|
||||
min-width: 100px;
|
||||
@@ -62,10 +63,11 @@
|
||||
|
||||
return editHtml
|
||||
+ html
|
||||
+ '\n----\n'
|
||||
+ '\n\n----\n\n'
|
||||
+ '<a href="https://docsify.js.org" target="_blank" style="color: inherit; font-weight: normal; text-decoration: none;">Powered by docsify</a>'
|
||||
})
|
||||
}
|
||||
},
|
||||
DocsifyCodefund.create('fae1f9a4-870c-4c25-b8e0-c80464f7a95c')
|
||||
]
|
||||
}
|
||||
</script>
|
||||
@@ -77,4 +79,4 @@
|
||||
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
+18
-22
@@ -4,7 +4,6 @@
|
||||
|
||||
By default, the hyperlink on the current page is recognized and the content is saved in `localStorage`. You can also specify the path to the files.
|
||||
|
||||
|
||||
```html
|
||||
<script>
|
||||
window.$docsify = {
|
||||
@@ -67,12 +66,6 @@ Configure by `data-ga`.
|
||||
<script src="//unpkg.com/docsify/lib/plugins/ga.min.js"></script>
|
||||
```
|
||||
|
||||
## front matter
|
||||
|
||||
```html
|
||||
<script src="//unpkg.com/docsify/lib/plugins/front-matter.min.js"></script>
|
||||
```
|
||||
|
||||
## emoji
|
||||
|
||||
The default is to support parsing emoji. For example `:100:` will be parsed to :100:. But it is not precise because there is no matching non-emoji string. If you need to correctly parse the emoji string, you need install this plugin.
|
||||
@@ -103,7 +96,6 @@ Exclude the special image
|
||||

|
||||
```
|
||||
|
||||
|
||||
## Edit on github
|
||||
|
||||
Add `Edit on github` button on every pages. Provided by [@njleonzhang](https://github.com/njleonzhang), check [document](https://github.com/njleonzhang/docsify-edit-on-github)
|
||||
@@ -116,27 +108,16 @@ When readers expand the demo box, the source code and description are shown ther
|
||||
|
||||
[Vue](https://njleonzhang.github.io/docsify-demo-box-vue/) and [React](https://njleonzhang.github.io/docsify-demo-box-react/) are both supported.
|
||||
|
||||
|
||||
## Copy to Clipboard
|
||||
|
||||
Add a simple `Click to copy` button to all preformatted code blocks to effortlessly allow users to copy example code from your docs. Provided by [@jperasmus](https://github.com/jperasmus)
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify-copy-code/styles.css">
|
||||
<script src="//unpkg.com/docsify-copy-code/index.js"></script>
|
||||
```
|
||||
|
||||
```javascript
|
||||
window.$docsify = {
|
||||
plugins: [
|
||||
window.DocsifyCopyCodePlugin.init()
|
||||
]
|
||||
}
|
||||
<script src="//unpkg.com/docsify-copy-code"></script>
|
||||
```
|
||||
|
||||
See [here](https://github.com/jperasmus/docsify-copy-code/blob/master/README.md) for more details.
|
||||
|
||||
|
||||
## Disqus
|
||||
|
||||
Disqus comments. https://disqus.com/
|
||||
@@ -152,7 +133,7 @@ Disqus comments. https://disqus.com/
|
||||
|
||||
## Gitalk
|
||||
|
||||
[Gitalk](https://github.com/gitalk/gitalk) is a modern comment component based on Github Issue and Preact.
|
||||
[Gitalk](https://github.com/gitalk/gitalk) is a modern comment component based on Github Issue and Preact.
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//unpkg.com/gitalk/dist/gitalk.css">
|
||||
@@ -172,7 +153,7 @@ Disqus comments. https://disqus.com/
|
||||
</script>
|
||||
```
|
||||
|
||||
## Navigation
|
||||
## Pagination
|
||||
|
||||
Pagination for docsify. By [@imyelo](https://github.com/imyelo)
|
||||
|
||||
@@ -181,3 +162,18 @@ Pagination for docsify. By [@imyelo](https://github.com/imyelo)
|
||||
<script src="//unpkg.com/docsify-pagination/dist/docsify-pagination.min.js"></script>
|
||||
```
|
||||
|
||||
## codefund
|
||||
|
||||
a [plugin](https://github.com/njleonzhang/docsify-plugin-codefund) to make it easy to join up [codefund](https://codesponsor.io/)
|
||||
|
||||
> codefund is formerly known as "codesponsor"
|
||||
|
||||
```
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
|
||||
window.$docsify = {
|
||||
plugins: [
|
||||
DocsifyCodefund.create('xxxx-xxx-xxx') // change to your codefund id
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Server client renderer
|
||||
# Server-Side Rendering
|
||||
|
||||
See https://docsify.now.sh
|
||||
|
||||
|
||||
@@ -54,3 +54,7 @@ If you have any ideas or would like to develop a new theme, you are welcome to s
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
## Other themes
|
||||
|
||||
- [docsify-themeable](https://jhildenbiddle.github.io/docsify-themeable/#/) A delightfully simple theme system for docsify.
|
||||
|
||||
+101
-51
@@ -14,8 +14,8 @@
|
||||
|
||||
## el
|
||||
|
||||
* 类型:`String`
|
||||
* 默认值:`#app`
|
||||
- 类型:`String`
|
||||
- 默认值:`#app`
|
||||
|
||||
docsify 初始化的挂载元素,可以是一个 CSS 选择器,默认为 `#app` 如果不存在就直接绑定在 `body` 上。
|
||||
|
||||
@@ -27,8 +27,8 @@ window.$docsify = {
|
||||
|
||||
## repo
|
||||
|
||||
* 类型:`String`
|
||||
* 默认值: `null`
|
||||
- 类型:`String`
|
||||
- 默认值: `null`
|
||||
|
||||
配置仓库地址或者 `username/repo` 的字符串,会在页面右上角渲染一个 [GitHub Corner](http://tholman.com/github-corners/) 挂件。
|
||||
|
||||
@@ -40,10 +40,10 @@ window.$docsify = {
|
||||
};
|
||||
```
|
||||
|
||||
## max-level
|
||||
## maxLevel
|
||||
|
||||
* 类型:`Number`
|
||||
* 默认值: `6`
|
||||
- 类型:`Number`
|
||||
- 默认值: `6`
|
||||
|
||||
默认情况下会抓取文档中所有标题渲染成目录,可配置最大支持渲染的标题层级。
|
||||
|
||||
@@ -53,23 +53,10 @@ window.$docsify = {
|
||||
};
|
||||
```
|
||||
|
||||
## maxLevel
|
||||
|
||||
* Type: `Number`
|
||||
* Default: `6`
|
||||
|
||||
Maximum Table of content level.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
maxLevel: 4
|
||||
};
|
||||
```
|
||||
|
||||
## loadNavbar
|
||||
|
||||
* 类型:`Boolean|String`
|
||||
* 默认值: `false`
|
||||
- 类型:`Boolean|String`
|
||||
- 默认值: `false`
|
||||
|
||||
加载自定义导航栏,参考[定制导航栏](zh-cn/custom-navbar.md) 了解用法。设置为 `true` 后会加载 `_navbar.md` 文件,也可以自定义加载的文件名。
|
||||
|
||||
@@ -85,8 +72,8 @@ window.$docsify = {
|
||||
|
||||
## loadSidebar
|
||||
|
||||
* 类型:`Boolean|String`
|
||||
* 默认值: `false`
|
||||
- 类型:`Boolean|String`
|
||||
- 默认值: `false`
|
||||
|
||||
加载自定义侧边栏,参考[多页文档](zh-cn/more-pages.md)。设置为 `true` 后会加载 `_sidebar.md` 文件,也可以自定义加载的文件名。
|
||||
|
||||
@@ -102,8 +89,8 @@ window.$docsify = {
|
||||
|
||||
## subMaxLevel
|
||||
|
||||
* 类型:`Number`
|
||||
* 默认值: `0`
|
||||
- 类型:`Number`
|
||||
- 默认值: `0`
|
||||
|
||||
自定义侧边栏后默认不会再生成目录,你也可以通过设置生成目录的最大层级开启这个功能。
|
||||
|
||||
@@ -115,8 +102,8 @@ window.$docsify = {
|
||||
|
||||
## auto2top
|
||||
|
||||
* 类型:`Boolean`
|
||||
* 默认值: `false`
|
||||
- 类型:`Boolean`
|
||||
- 默认值: `false`
|
||||
|
||||
切换页面后是否自动跳转到页面顶部。
|
||||
|
||||
@@ -128,8 +115,8 @@ window.$docsify = {
|
||||
|
||||
## homepage
|
||||
|
||||
* 类型:`String`
|
||||
* 默认值: `README.md`
|
||||
- 类型:`String`
|
||||
- 默认值: `README.md`
|
||||
|
||||
设置首页文件加载路径。适合不想将 `README.md` 作为入口文件渲染,或者是文档存放在其他位置的情况使用。
|
||||
|
||||
@@ -146,7 +133,7 @@ window.$docsify = {
|
||||
|
||||
## basePath
|
||||
|
||||
* 类型:`String`
|
||||
- 类型:`String`
|
||||
|
||||
文档加载的根路径,可以是二级路径或者是其他域名的路径。
|
||||
|
||||
@@ -165,8 +152,8 @@ window.$docsify = {
|
||||
|
||||
## coverpage
|
||||
|
||||
* 类型:`Boolean|String`
|
||||
* 默认值: `false`
|
||||
- 类型:`Boolean|String`
|
||||
- 默认值: `false`
|
||||
|
||||
启用[封面页](zh-cn/cover.md)。开启后是加载 `_coverpage.md` 文件,也可以自定义文件名。
|
||||
|
||||
@@ -188,9 +175,21 @@ window.$docsify = {
|
||||
};
|
||||
```
|
||||
|
||||
## logo
|
||||
|
||||
- Type: `String`
|
||||
|
||||
Website logo as it appears in the sidebar, you can resize by CSS.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
logo: '/_media/icon.svg'
|
||||
};
|
||||
```
|
||||
|
||||
## name
|
||||
|
||||
* 类型:`String`
|
||||
- 类型:`String`
|
||||
|
||||
文档标题,会显示在侧边栏顶部。
|
||||
|
||||
@@ -202,8 +201,8 @@ window.$docsify = {
|
||||
|
||||
## nameLink
|
||||
|
||||
* 类型:`String`
|
||||
* 默认值:`window.location.pathname`
|
||||
- 类型:`String`
|
||||
- 默认值:`window.location.pathname`
|
||||
|
||||
点击文档标题后跳转的链接地址。
|
||||
|
||||
@@ -221,7 +220,7 @@ window.$docsify = {
|
||||
|
||||
## markdown
|
||||
|
||||
* 类型: `Object|Function`
|
||||
- 类型: `Object|Function`
|
||||
|
||||
参考 [Markdown 配置](zh-cn/markdown.md)。
|
||||
|
||||
@@ -247,7 +246,7 @@ window.$docsify = {
|
||||
|
||||
## themeColor
|
||||
|
||||
* 类型:`String`
|
||||
- 类型:`String`
|
||||
|
||||
替换主题色。利用 [CSS3 支持变量](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables)的特性,对于老的浏览器有 polyfill 处理。
|
||||
|
||||
@@ -259,7 +258,7 @@ window.$docsify = {
|
||||
|
||||
## alias
|
||||
|
||||
* 类型:`Object`
|
||||
- 类型:`Object`
|
||||
|
||||
定义路由别名,可以更自由的定义路由规则。 支持正则。
|
||||
|
||||
@@ -277,7 +276,7 @@ window.$docsify = {
|
||||
|
||||
## autoHeader
|
||||
|
||||
* 类型:`Boolean`
|
||||
- 类型:`Boolean`
|
||||
|
||||
同时设置 `loadSidebar` 和 `autoHeader` 后,可以根据 `_sidebar.md` 的内容自动为每个页面增加标题。[#78](https://github.com/QingWei-Li/docsify/issues/78)
|
||||
|
||||
@@ -290,7 +289,7 @@ window.$docsify = {
|
||||
|
||||
## executeScript
|
||||
|
||||
* 类型:`Boolean`
|
||||
- 类型:`Boolean`
|
||||
|
||||
执行文档里的 script 标签里的脚本,只执行第一个 script ([demo](zh-cn/themes.md))。 如果 Vue 存在,则自动开启。
|
||||
|
||||
@@ -312,7 +311,7 @@ window.$docsify = {
|
||||
|
||||
## noEmoji
|
||||
|
||||
* type: `Boolean`
|
||||
- type: `Boolean`
|
||||
|
||||
禁用 emoji 解析。
|
||||
|
||||
@@ -324,7 +323,7 @@ window.$docsify = {
|
||||
|
||||
## mergeNavbar
|
||||
|
||||
* type: `Boolean`
|
||||
- type: `Boolean`
|
||||
|
||||
小屏设备下合并导航栏到侧边栏。
|
||||
|
||||
@@ -336,7 +335,7 @@ window.$docsify = {
|
||||
|
||||
## formatUpdated
|
||||
|
||||
* type: `String|Function`
|
||||
- type: `String|Function`
|
||||
|
||||
我们可以显示文档更新日期通过 **{docsify-updated<span>}</span>** 变量. 并且格式化日期通过 `formatUpdated`。参考 https://github.com/lukeed/tinydate#patterns
|
||||
|
||||
@@ -354,8 +353,8 @@ window.$docsify = {
|
||||
|
||||
## externalLinkTarget
|
||||
|
||||
* type: `String`
|
||||
* default: `_blank`
|
||||
- type: `String`
|
||||
- default: `_blank`
|
||||
|
||||
当前默认为 \_blank, 配置一下就可以:
|
||||
|
||||
@@ -367,8 +366,8 @@ window.$docsify = {
|
||||
|
||||
## routerMode
|
||||
|
||||
* type: `String`
|
||||
* default: `history`
|
||||
- type: `String`
|
||||
- default: `history`
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -378,7 +377,7 @@ window.$docsify = {
|
||||
|
||||
## noCompileLinks
|
||||
|
||||
* 类型: `Array`
|
||||
- 类型: `Array`
|
||||
|
||||
有时我们不希望 docsify 处理我们的链接。 参考 [#203](https://github.com/QingWei-Li/docsify/issues/203)
|
||||
|
||||
@@ -390,7 +389,7 @@ window.$docsify = {
|
||||
|
||||
## requestHeaders
|
||||
|
||||
* type: `Object`
|
||||
- type: `Object`
|
||||
|
||||
设置请求资源的请求头。
|
||||
|
||||
@@ -404,7 +403,7 @@ window.$docsify = {
|
||||
|
||||
## ext
|
||||
|
||||
* type: `String`
|
||||
- type: `String`
|
||||
|
||||
资源的文件扩展名。
|
||||
|
||||
@@ -413,3 +412,54 @@ window.$docsify = {
|
||||
ext: '.md'
|
||||
};
|
||||
```
|
||||
|
||||
## fallbackLanguages
|
||||
|
||||
- type: `Array<string>`
|
||||
|
||||
List of languages that will fallback to the default language when a page is request and didn't exists for the given local.
|
||||
|
||||
Example:
|
||||
|
||||
- try to fetch the page of `/de/overview`. If this page exists, it'll be displayed
|
||||
- then try to fetch the default page `/overview` (depending on the default language). If this page exists, it'll be displayed
|
||||
- then display 404 page.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
fallbackLanguages: ['fr', 'de']
|
||||
};
|
||||
```
|
||||
|
||||
## notFoundPage
|
||||
|
||||
- type: `Boolean` | `String` | `Object`
|
||||
|
||||
Load the `_404.md` file:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: true
|
||||
};
|
||||
```
|
||||
|
||||
Load the customised path of the 404 page:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: 'my404.md'
|
||||
};
|
||||
```
|
||||
|
||||
Load the right 404 page according to the localisation:
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
notFoundPage: {
|
||||
'/': '_404.md',
|
||||
'/de': 'de/_404.md'
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
> Note: The options with fallbackLanguages didn't work with the `notFoundPage` options.
|
||||
|
||||
@@ -46,10 +46,10 @@ _\_navbar.md_
|
||||
|
||||
```markdown
|
||||
* 基础
|
||||
* [快速开始](zh-cn/quickstart.md)
|
||||
* [多页文档](zh-cn/more-pages.md)
|
||||
* [定制导航栏](zh-cn/custom-navbar.md)
|
||||
* [封面](zh-cn/cover.md)
|
||||
* [快速开始](zh-cn/quickstart.md)
|
||||
* [多页文档](zh-cn/more-pages.md)
|
||||
* [定制导航栏](zh-cn/custom-navbar.md)
|
||||
* [封面](zh-cn/cover.md)
|
||||
|
||||
* 配置
|
||||
* [配置项](zh-cn/configuration.md)
|
||||
@@ -61,4 +61,4 @@ _\_navbar.md_
|
||||
|
||||
效果图
|
||||
|
||||

|
||||

|
||||
|
||||
+17
-4
@@ -5,24 +5,24 @@
|
||||
## GitHub Pages
|
||||
|
||||
GitHub Pages 支持从三个地方读取文件
|
||||
|
||||
- `docs/` 目录
|
||||
- master 分支
|
||||
- gh-pages 分支
|
||||
|
||||
我们推荐直接将文档放在 `docs/` 目录下,在设置页面开启 **GitHub Pages** 功能并选择 `master branch /docs folder` 选项。
|
||||
|
||||

|
||||

|
||||
|
||||
!> 可以将文档放在根目录下,然后选择 **master 分支** 作为文档目录。
|
||||
|
||||
|
||||
## GitLab Pages
|
||||
|
||||
如果你正在部署你的主分支, 在 `.gitlab-ci.yml` 中包含以下脚本:
|
||||
|
||||
?> `.public` 的解决方法是这样的,`cp` 不会无限循环的将 `public/` 复制到自身。
|
||||
|
||||
``` YAML
|
||||
```YAML
|
||||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
@@ -38,7 +38,6 @@ pages:
|
||||
|
||||
!> 你可以用 `- cp -r docs/. public` 替换脚本, 如果 `./docs` 是你的 docsify 子文件夹。
|
||||
|
||||
|
||||
## VPS
|
||||
|
||||
和部署所有静态网站一样,只需将服务器的访问根目录设定为 `index.html` 文件。
|
||||
@@ -56,3 +55,17 @@ server {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Netlify
|
||||
|
||||
1. Login to your [Netlify](https://www.netlify.com/) account.
|
||||
2. In the [dashboard](https://app.netlify.com/) page, click **New site from Git**.
|
||||
3. Choose a repository where you store your docs, leave the **Build Command** area blank, fill in the Publish directory area with the directory of your `index.html`, for example it should be docs if you populated it at `docs/index.html`.
|
||||
|
||||
### HTML5 router
|
||||
|
||||
When using the HTML5 router, you need to set up redirect rules that redirect all requests to your `index.html`, it's pretty simple when you're using Netlify, populate a `\redirects` file in the docs directory and you're all set:
|
||||
|
||||
```sh
|
||||
/* /index.html 200
|
||||
```
|
||||
|
||||
@@ -5,14 +5,14 @@ docsify 4.6 开始支持嵌入任何类型的文件到文档里。你可以将
|
||||
这是一个嵌入 Markdown 文件的例子。
|
||||
|
||||
```markdown
|
||||
[filename](_media/example.md ':include')
|
||||
[filename](../_media/example.md ':include')
|
||||
```
|
||||
|
||||
`example.md` 文件的内容将会直接显示在这里
|
||||
|
||||
[filename](_media/example.md ':include')
|
||||
[filename](../_media/example.md ':include')
|
||||
|
||||
你可以查看 [example.md](_media/example.md ':ignore') 原始内容对比效果。
|
||||
你可以查看 [example.md](../_media/example.md ':ignore') 原始内容对比效果。
|
||||
|
||||
通常情况下,这样的语法将会被当作链接处理。但是在 docsify 里,如果你添加一个 `:include` 选项,它就会被当作文件嵌入。
|
||||
|
||||
@@ -29,12 +29,12 @@ docsify 4.6 开始支持嵌入任何类型的文件到文档里。你可以将
|
||||
当然,你也可以强制设置嵌入类型。例如你想将 Markdown 文件当作一个 `code block` 嵌入。
|
||||
|
||||
```markdown
|
||||
[filename](_media/example.md ':include :type=code')
|
||||
[filename](../_media/example.md ':include :type=code')
|
||||
```
|
||||
|
||||
你将得到
|
||||
|
||||
[filename](_media/example.md ':include :type=code')
|
||||
[filename](../_media/example.md ':include :type=code')
|
||||
|
||||
## 标签属性
|
||||
|
||||
@@ -53,11 +53,11 @@ docsify 4.6 开始支持嵌入任何类型的文件到文档里。你可以将
|
||||
如果是嵌入一个代码块,你可以设置高亮的语言,或者让它自动识别。这里是手动设置高亮语言
|
||||
|
||||
```markdown
|
||||
[](_media/example.html ':include :type=code text')
|
||||
[](../_media/example.html ':include :type=code text')
|
||||
```
|
||||
|
||||
⬇️
|
||||
|
||||
[](_media/example.html ':include :type=code text')
|
||||
[](../_media/example.html ':include :type=code text')
|
||||
|
||||
?> 如何高亮代码?你可以查看[这份文档](language-highlight.md).
|
||||
|
||||
+22
-12
@@ -56,17 +56,27 @@ docsify 扩展了一些 Markdown 语法,可以让文档更易读。
|
||||
## Github 任务列表
|
||||
|
||||
```md
|
||||
* [ ] foo
|
||||
* bar
|
||||
* [x] baz
|
||||
* [] bam <~ not working
|
||||
* [ ] bim
|
||||
* [ ] lim
|
||||
- [ ] foo
|
||||
- bar
|
||||
- [x] baz
|
||||
- [] bam <~ not working
|
||||
- [ ] bim
|
||||
- [ ] lim
|
||||
```
|
||||
|
||||
* [ ] foo
|
||||
* bar
|
||||
* [x] baz
|
||||
* [] bam <~ not working
|
||||
* [ ] bim
|
||||
* [ ] lim
|
||||
- [ ] foo
|
||||
- bar
|
||||
- [x] baz
|
||||
- [] bam <~ not working
|
||||
- [ ] bim
|
||||
- [ ] lim
|
||||
|
||||
## Image resizing
|
||||
|
||||
```md
|
||||

|
||||

|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Markdown 配置
|
||||
|
||||
内置的 Markdown 解析器是 [marked](https://github.com/chjj/marked),可以修改它的配置。同时可以直接配置 `renderer`。
|
||||
内置的 Markdown 解析器是 [marked](https://github.com/markedjs/marked),可以修改它的配置。同时可以直接配置 `renderer`。
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
@@ -15,7 +15,7 @@ window.$docsify = {
|
||||
}
|
||||
```
|
||||
|
||||
?> 完整配置参数参考 [marked 文档](https://github.com/chjj/marked#options-1)
|
||||
?> 完整配置参数参考 [marked 文档](https://github.com/markedjs/marked#options-1)
|
||||
|
||||
当然也可以完全定制 Markdown 解析规则。
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ docs/zh-cn/guide.md => http://domain.com/zh-cn/guide
|
||||
|
||||
默认情况下,侧边栏会根据当前文档的标题生成目录。也可以设置文档链接,通过 Markdown 文件生成,效果如当前的文档的侧边栏。
|
||||
|
||||
首先配置 `loadSidebar` 选项,具体配置规则见[配置项#loadSidebar](configuration.md#loadsidebar)。
|
||||
首先配置 `loadSidebar` 选项,具体配置规则见[配置项#loadSidebar](zh-cn/configuration.md#loadsidebar)。
|
||||
|
||||
```html
|
||||
<script>
|
||||
|
||||
+19
-21
@@ -4,7 +4,6 @@
|
||||
|
||||
全文搜索插件会根据当前页面上的超链接获取文档内容,在 `localStorage` 内建立文档索引。默认过期时间为一天,当然我们可以自己指定需要缓存的文件列表或者配置过期时间。
|
||||
|
||||
|
||||
```html
|
||||
<script>
|
||||
window.$docsify = {
|
||||
@@ -91,7 +90,6 @@ When readers expand the demo box, the source code and description are shown ther
|
||||
|
||||
[Vue](https://njleonzhang.github.io/docsify-demo-box-vue/) and [React](https://njleonzhang.github.io/docsify-demo-box-react/) are both supported.
|
||||
|
||||
|
||||
## 图片缩放 - Zoom image
|
||||
|
||||
Medium's 风格的图片缩放插件. 基于 [medium-zoom](https://github.com/francoischalifour/medium-zoom)。
|
||||
@@ -100,41 +98,26 @@ Medium's 风格的图片缩放插件. 基于 [medium-zoom](https://github.com/fr
|
||||
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.js"></script>
|
||||
```
|
||||
|
||||
|
||||
忽略某张图片
|
||||
|
||||
```markdown
|
||||

|
||||
```
|
||||
|
||||
|
||||
|
||||
## 在 Github 上编辑
|
||||
|
||||
在每一页上添加 `Edit on github` 按钮. 由第三方库提供, 查看 [document](https://github.com/njleonzhang/docsify-edit-on-github)
|
||||
|
||||
|
||||
## Copy to Clipboard
|
||||
|
||||
Add a simple `Click to copy` button to all preformatted code blocks to effortlessly allow users to copy example code from your docs. Provided by [@jperasmus](https://github.com/jperasmus)
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify-copy-code/styles.css">
|
||||
<script src="//unpkg.com/docsify-copy-code/index.js"></script>
|
||||
```
|
||||
|
||||
```javascript
|
||||
window.$docsify = {
|
||||
plugins: [
|
||||
window.DocsifyCopyCodePlugin.init()
|
||||
]
|
||||
}
|
||||
<script src="//unpkg.com/docsify-copy-code"></script>
|
||||
```
|
||||
|
||||
See [here](https://github.com/jperasmus/docsify-copy-code/blob/master/README.md) for more details.
|
||||
|
||||
|
||||
|
||||
## Disqus
|
||||
|
||||
Disqus comments. https://disqus.com/
|
||||
@@ -148,10 +131,9 @@ Disqus comments. https://disqus.com/
|
||||
<script src="//unpkg.com/docsify/lib/plugins/disqus.min.js"></script>
|
||||
```
|
||||
|
||||
|
||||
## Gitalk
|
||||
|
||||
[Gitalk](https://github.com/gitalk/gitalk) is a modern comment component based on Github Issue and Preact.
|
||||
[Gitalk](https://github.com/gitalk/gitalk) is a modern comment component based on Github Issue and Preact.
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//unpkg.com/gitalk/dist/gitalk.css">
|
||||
@@ -171,7 +153,7 @@ Disqus comments. https://disqus.com/
|
||||
</script>
|
||||
```
|
||||
|
||||
## Navigation
|
||||
## Pagination
|
||||
|
||||
Pagination for docsify. By [@imyelo](https://github.com/imyelo)
|
||||
|
||||
@@ -179,3 +161,19 @@ Pagination for docsify. By [@imyelo](https://github.com/imyelo)
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
<script src="//unpkg.com/docsify-pagination/dist/docsify-pagination.min.js"></script>
|
||||
```
|
||||
|
||||
## Code Fund
|
||||
|
||||
帮你快速接入[Code Fund](https://codesponsor.io/)的[插件](https://github.com/njleonzhang/docsify-plugin-codefund), 由[@njleonzhang](https://github.com/njleonzhang)提供。
|
||||
|
||||
> Code Fund 以前叫 codesponsor
|
||||
|
||||
```
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
|
||||
window.$docsify = {
|
||||
plugins: [
|
||||
DocsifyCodefund.create('51d43327-eea3-4e27-bd44-e075e67a84fb') // 把这个id改成你的codefund id
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -54,3 +54,8 @@
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
## Other themes
|
||||
|
||||
- [docsify-themeable](https://jhildenbiddle.github.io/docsify-themeable/#/) A delightfully simple theme system for docsify.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>docsify</title>
|
||||
@@ -14,6 +15,7 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script>
|
||||
@@ -22,6 +24,7 @@
|
||||
'.*?/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG',
|
||||
'/.*/_navbar.md': '/_navbar.md'
|
||||
},
|
||||
notFoundPage: '_404.html',
|
||||
auto2top: true,
|
||||
basePath: '/docs/',
|
||||
executeScript: true,
|
||||
@@ -33,14 +36,14 @@
|
||||
mergeNavbar: true,
|
||||
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||
plugins: [
|
||||
function(hook, vm) {
|
||||
function (hook, vm) {
|
||||
hook.beforeEach(function (html) {
|
||||
var url = 'https://github.com/QingWei-Li/docsify/blob/master/' + vm.route.file
|
||||
var editHtml = '[:memo: Edit Document](' + url + ')\n'
|
||||
|
||||
|
||||
return editHtml
|
||||
+ html
|
||||
+ '\n----\n'
|
||||
+ '\n\n----\n\n'
|
||||
+ 'Last modified {docsify-updated} '
|
||||
+ editHtml
|
||||
})
|
||||
@@ -50,4 +53,5 @@
|
||||
</script>
|
||||
<script src="/lib/docsify.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
+503
-281
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@ if (fixedPath !== location.href) {
|
||||
location.href = fixedPath;
|
||||
}
|
||||
|
||||
function install (hook, vm) {
|
||||
function install(hook, vm) {
|
||||
var dom = Docsify.dom;
|
||||
var disqus = vm.config.disqus;
|
||||
if (!disqus) {
|
||||
@@ -16,7 +16,7 @@ function install (hook, vm) {
|
||||
|
||||
script.async = true;
|
||||
script.src = "https://" + disqus + ".disqus.com/embed.js";
|
||||
script.setAttribute('data-timestamp', +new Date());
|
||||
script.setAttribute('data-timestamp', Number(new Date()));
|
||||
dom.appendTo(dom.body, script);
|
||||
});
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
!function(){var i=location.href.replace("/-/","/#/");i!==location.href&&(location.href=i);$docsify.plugins=[].concat(function(i,t){var e=Docsify.dom,o=t.config.disqus;if(!o)throw Error("$docsify.disqus is required");i.init(function(i){var t=e.create("script");t.async=!0,t.src="https://"+o+".disqus.com/embed.js",t.setAttribute("data-timestamp",+new Date),e.appendTo(e.body,t)}),i.mounted(function(i){var o=e.create("div");o.id="disqus_thread";var n=e.getNode("#main");o.style="width: "+n.clientWidth+"px; margin: 0 auto 20px;",e.appendTo(e.find(".content"),o),window.disqus_config=function(){this.page.url=location.origin+"/-"+t.route.path,this.page.identifier=t.route.path,this.page.title=document.title}}),i.doneEach(function(i){void 0!==window.DISQUS&&window.DISQUS.reset({reload:!0,config:function(){this.page.url=location.origin+"/-"+t.route.path,this.page.identifier=t.route.path,this.page.title=document.title}})})},$docsify.plugins)}();
|
||||
!function(){var i=location.href.replace("/-/","/#/");i!==location.href&&(location.href=i);$docsify.plugins=[].concat(function(i,t){var e=Docsify.dom,o=t.config.disqus;if(!o)throw Error("$docsify.disqus is required");i.init(function(i){var t=e.create("script");t.async=!0,t.src="https://"+o+".disqus.com/embed.js",t.setAttribute("data-timestamp",Number(new Date)),e.appendTo(e.body,t)}),i.mounted(function(i){var o=e.create("div");o.id="disqus_thread";var n=e.getNode("#main");o.style="width: "+n.clientWidth+"px; margin: 0 auto 20px;",e.appendTo(e.find(".content"),o),window.disqus_config=function(){this.page.url=location.origin+"/-"+t.route.path,this.page.identifier=t.route.path,this.page.title=document.title}}),i.doneEach(function(i){void 0!==window.DISQUS&&window.DISQUS.reset({reload:!0,config:function(){this.page.url=location.origin+"/-"+t.route.path,this.page.identifier=t.route.path,this.page.title=document.title}})})},$docsify.plugins)}();
|
||||
|
||||
@@ -888,12 +888,12 @@ var AllGithubEmoji = [
|
||||
'zzz'
|
||||
];
|
||||
|
||||
// emoji from All-Github-Emoji-Icons
|
||||
// Emoji from All-Github-Emoji-Icons
|
||||
// https://github.com/scotch-io/All-Github-Emoji-Icons
|
||||
window.emojify = function (match, $1) {
|
||||
return AllGithubEmoji.indexOf($1) === -1
|
||||
? match
|
||||
: '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' +
|
||||
return AllGithubEmoji.indexOf($1) === -1 ?
|
||||
match :
|
||||
'<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' +
|
||||
$1 +
|
||||
'.png" alt="' +
|
||||
$1 +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(function () {
|
||||
function handleExternalScript () {
|
||||
function handleExternalScript() {
|
||||
var container = Docsify.dom.getNode('#main');
|
||||
var scripts = Docsify.dom.findAll(container, 'script');
|
||||
|
||||
|
||||
@@ -485,7 +485,7 @@ var install = function (hook, vm) {
|
||||
var attributes = ref.attributes;
|
||||
var body = ref.body;
|
||||
|
||||
Docsify.util.merge(vm.config, attributes.config);
|
||||
vm.frontmatter = attributes;
|
||||
|
||||
return body
|
||||
});
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
!function(){var e=[],n=[],t=0,r={regLevel:new RegExp("^([\\s\\-]+)"),invalidLine:new RegExp("^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$"),dashesString:new RegExp('^\\s*\\"([^\\"]*)\\"\\s*$'),quotesString:new RegExp("^\\s*\\'([^\\']*)\\'\\s*$"),float:new RegExp("^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$"),integer:new RegExp("^[+-]?[0-9]+$"),array:new RegExp("\\[\\s*(.*)\\s*\\]"),map:new RegExp("\\{\\s*(.*)\\s*\\}"),key_value:new RegExp("([a-z0-9_-][ a-z0-9_-]*):( .+)","i"),single_key_value:new RegExp("^([a-z0-9_-][ a-z0-9_-]*):( .+?)$","i"),key:new RegExp("([a-z0-9_-][ a-z0-9_-]+):( .+)?","i"),item:new RegExp("^-\\s+"),trim:new RegExp("^\\s+|\\s+$"),comment:new RegExp("([^\\'\\\"#]+([\\'\\\"][^\\'\\\"]*[\\'\\\"])*)*(#.*)?")};function i(e){return{parent:null,length:0,level:e,lines:[],children:[],addChild:function(e){this.children.push(e),e.parent=this,++this.length}}}function l(e){var n=null;if("true"==(e=e.replace(r.trim,"")))return!0;if("false"==e)return!1;if(".NaN"==e)return Number.NaN;if("null"==e)return null;if(".inf"==e)return Number.POSITIVE_INFINITY;if("-.inf"==e)return Number.NEGATIVE_INFINITY;if(n=e.match(r.dashesString))return n[1];if(n=e.match(r.quotesString))return n[1];if(n=e.match(r.float))return parseFloat(n[0]);if(n=e.match(r.integer))return parseInt(n[0]);if(isNaN(n=Date.parse(e))){if(n=e.match(r.single_key_value)){return(u={})[n[1]]=l(n[2]),u}if(n=e.match(r.array)){for(var t=0,i=" ",u=[],a="",s=!1,f=0,h=n[1].length;f<h;++f){if("'"==(i=n[1][f])||'"'==i){if(!1===s){s=i,a+=i;continue}if("'"==i&&"'"==s||'"'==i&&'"'==s){s=!1,a+=i;continue}}else if(!1!==s||"["!=i&&"{"!=i)if(!1!==s||"]"!=i&&"}"!=i){if(!1===s&&0==t&&","==i){u.push(l(a)),a="";continue}}else--t;else++t;a+=i}return a.length>0&&u.push(l(a)),u}if(n=e.match(r.map)){for(t=0,i=" ",u=[],a="",s=!1,f=0,h=n[1].length;f<h;++f){if("'"==(i=n[1][f])||'"'==i){if(!1===s){s=i,a+=i;continue}if("'"==i&&"'"==s||'"'==i&&'"'==s){s=!1,a+=i;continue}}else if(!1!==s||"["!=i&&"{"!=i)if(!1!==s||"]"!=i&&"}"!=i){if(!1===s&&0==t&&","==i){u.push(a),a="";continue}}else--t;else++t;a+=i}a.length>0&&u.push(a);var o={};for(f=0,h=u.length;f<h;++f)(n=u[f].match(r.key_value))&&(o[n[1]]=l(n[2]));return o}return e}return new Date(n)}function u(e){for(var n=e.lines,t=e.children,r=[n.join(" ")],i=0,l=t.length;i<l;++i)r.push(u(t[i]));return r.join("\n")}function a(e){for(var n=e.lines,t=e.children,r=n.join("\n"),i=0,l=t.length;i<l;++i)r+=a(t[i]);return r}function s(t){return function t(i){for(var s=null,f={},h=null,o=null,c=null,p=-1,g=[],v=!0,d=0,m=i.length;d<m;++d)if(-1==p||p==i[d].level){g.push(d),p=i[d].level,h=i[d].lines,o=i[d].children,c=null;for(var w=0,E=h.length;w<E;++w){var x=h[w];if(s=x.match(r.key)){var y=s[1];if("-"==y[0]&&(y=y.replace(r.item,""),v&&(v=!1,void 0===f.length&&(f=[])),null!=c&&f.push(c),c={},v=!0),void 0!==s[2]){var b=s[2].replace(r.trim,"");if("&"==b[0]){var R=t(o);null!=c?c[y]=R:f[y]=R,n[b.substr(1)]=R}else if("|"==b[0])null!=c?c[y]=a(o.shift()):f[y]=a(o.shift());else if("*"==b[0]){var N=b.substr(1),_={};if(void 0===n[N])e.push("Reference '"+N+"' not found!");else{for(var $ in n[N])_[$]=n[N][$];null!=c?c[y]=_:f[y]=_}}else">"==b[0]?null!=c?c[y]=u(o.shift()):f[y]=u(o.shift()):null!=c?c[y]=l(b):f[y]=l(b)}else null!=c?c[y]=t(o):f[y]=t(o)}else{if(x.match(/^-\s*$/)){v&&(v=!1,void 0===f.length&&(f=[])),null!=c&&f.push(c),c={},v=!0;continue}if(s=x.match(/^-\s*(.*)/)){null!=c?c.push(l(s[1])):(v&&(v=!1,void 0===f.length&&(f=[])),f.push(l(s[1])));continue}}}null!=c&&(v&&(v=!1,void 0===f.length&&(f=[])),f.push(c))}for(d=g.length-1;d>=0;--d)i.splice.call(i,g[d],1);return f}(t.children)}function f(l){e=[],n=[],t=(new Date).getTime();var u=s(function(n){var t,l=r.regLevel,u=r.invalidLine,a=n.split("\n"),s=0,f=0,h=[],o=new i(-1),c=new i(0);o.addChild(c);var p=[],g="";h.push(c),p.push(s);for(var v=0,d=a.length;v<d;++v)if(!(g=a[v]).match(u)){if((s=(t=l.exec(g))?t[1].length:0)>f){var m=c;c=new i(s),m.addChild(c),h.push(c),p.push(s)}else if(s<f){for(var w=!1,E=p.length-1;E>=0;--E)if(p[E]==s){c=new i(s),h.push(c),p.push(s),null!=h[E].parent&&h[E].parent.addChild(c),w=!0;break}if(!w)return void e.push("Error: Invalid indentation at line "+v+": "+g)}c.lines.push(g.replace(r.trim,"")),f=s}return o}(function(e){var n,t=e.split("\n"),i=r.comment;for(var l in t)(n=t[l].match(i))&&void 0!==n[3]&&(t[l]=n[0].substr(0,n[0].length-n[3].length));return t.join("\n")}(l)));return t=(new Date).getTime()-t,u}var h=new RegExp("^(\\ufeff?(= yaml =|---)$([\\s\\S]*?)(?:\\2|\\.\\.\\.)$(?:\\n)?)","m");function o(e){var n=(e=e||"").split(/(\r?\n)/);return n[0]&&/= yaml =|---/.test(n[0])?function(e){var n=h.exec(e);if(!n)return{attributes:{},body:e};var t=n[n.length-1].replace(/^\s+|\s+$/g,""),r=f(t)||{},i=e.replace(n[0],"");return{attributes:r,body:i,frontmatter:t}}(e):{attributes:{},body:e}}$docsify.plugins=[].concat(function(e,n){e.beforeEach(function(e){var t=o(e),r=t.attributes,i=t.body;return Docsify.util.merge(n.config,r.config),i})},$docsify.plugins)}();
|
||||
!function(){var e=[],n=[],t=0,r={regLevel:new RegExp("^([\\s\\-]+)"),invalidLine:new RegExp("^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$"),dashesString:new RegExp('^\\s*\\"([^\\"]*)\\"\\s*$'),quotesString:new RegExp("^\\s*\\'([^\\']*)\\'\\s*$"),float:new RegExp("^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$"),integer:new RegExp("^[+-]?[0-9]+$"),array:new RegExp("\\[\\s*(.*)\\s*\\]"),map:new RegExp("\\{\\s*(.*)\\s*\\}"),key_value:new RegExp("([a-z0-9_-][ a-z0-9_-]*):( .+)","i"),single_key_value:new RegExp("^([a-z0-9_-][ a-z0-9_-]*):( .+?)$","i"),key:new RegExp("([a-z0-9_-][ a-z0-9_-]+):( .+)?","i"),item:new RegExp("^-\\s+"),trim:new RegExp("^\\s+|\\s+$"),comment:new RegExp("([^\\'\\\"#]+([\\'\\\"][^\\'\\\"]*[\\'\\\"])*)*(#.*)?")};function i(e){return{parent:null,length:0,level:e,lines:[],children:[],addChild:function(e){this.children.push(e),e.parent=this,++this.length}}}function l(e){var n=null;if("true"==(e=e.replace(r.trim,"")))return!0;if("false"==e)return!1;if(".NaN"==e)return Number.NaN;if("null"==e)return null;if(".inf"==e)return Number.POSITIVE_INFINITY;if("-.inf"==e)return Number.NEGATIVE_INFINITY;if(n=e.match(r.dashesString))return n[1];if(n=e.match(r.quotesString))return n[1];if(n=e.match(r.float))return parseFloat(n[0]);if(n=e.match(r.integer))return parseInt(n[0]);if(isNaN(n=Date.parse(e))){if(n=e.match(r.single_key_value)){return(u={})[n[1]]=l(n[2]),u}if(n=e.match(r.array)){for(var t=0,i=" ",u=[],a="",s=!1,f=0,h=n[1].length;f<h;++f){if("'"==(i=n[1][f])||'"'==i){if(!1===s){s=i,a+=i;continue}if("'"==i&&"'"==s||'"'==i&&'"'==s){s=!1,a+=i;continue}}else if(!1!==s||"["!=i&&"{"!=i)if(!1!==s||"]"!=i&&"}"!=i){if(!1===s&&0==t&&","==i){u.push(l(a)),a="";continue}}else--t;else++t;a+=i}return a.length>0&&u.push(l(a)),u}if(n=e.match(r.map)){for(t=0,i=" ",u=[],a="",s=!1,f=0,h=n[1].length;f<h;++f){if("'"==(i=n[1][f])||'"'==i){if(!1===s){s=i,a+=i;continue}if("'"==i&&"'"==s||'"'==i&&'"'==s){s=!1,a+=i;continue}}else if(!1!==s||"["!=i&&"{"!=i)if(!1!==s||"]"!=i&&"}"!=i){if(!1===s&&0==t&&","==i){u.push(a),a="";continue}}else--t;else++t;a+=i}a.length>0&&u.push(a);var o={};for(f=0,h=u.length;f<h;++f)(n=u[f].match(r.key_value))&&(o[n[1]]=l(n[2]));return o}return e}return new Date(n)}function u(e){for(var n=e.lines,t=e.children,r=[n.join(" ")],i=0,l=t.length;i<l;++i)r.push(u(t[i]));return r.join("\n")}function a(e){for(var n=e.lines,t=e.children,r=n.join("\n"),i=0,l=t.length;i<l;++i)r+=a(t[i]);return r}function s(t){return function t(i){for(var s=null,f={},h=null,o=null,c=null,p=-1,g=[],v=!0,d=0,m=i.length;d<m;++d)if(-1==p||p==i[d].level){g.push(d),p=i[d].level,h=i[d].lines,o=i[d].children,c=null;for(var w=0,E=h.length;w<E;++w){var x=h[w];if(s=x.match(r.key)){var b=s[1];if("-"==b[0]&&(b=b.replace(r.item,""),v&&(v=!1,void 0===f.length&&(f=[])),null!=c&&f.push(c),c={},v=!0),void 0!==s[2]){var y=s[2].replace(r.trim,"");if("&"==y[0]){var R=t(o);null!=c?c[b]=R:f[b]=R,n[y.substr(1)]=R}else if("|"==y[0])null!=c?c[b]=a(o.shift()):f[b]=a(o.shift());else if("*"==y[0]){var N=y.substr(1),_={};if(void 0===n[N])e.push("Reference '"+N+"' not found!");else{for(var $ in n[N])_[$]=n[N][$];null!=c?c[b]=_:f[b]=_}}else">"==y[0]?null!=c?c[b]=u(o.shift()):f[b]=u(o.shift()):null!=c?c[b]=l(y):f[b]=l(y)}else null!=c?c[b]=t(o):f[b]=t(o)}else{if(x.match(/^-\s*$/)){v&&(v=!1,void 0===f.length&&(f=[])),null!=c&&f.push(c),c={},v=!0;continue}if(s=x.match(/^-\s*(.*)/)){null!=c?c.push(l(s[1])):(v&&(v=!1,void 0===f.length&&(f=[])),f.push(l(s[1])));continue}}}null!=c&&(v&&(v=!1,void 0===f.length&&(f=[])),f.push(c))}for(d=g.length-1;d>=0;--d)i.splice.call(i,g[d],1);return f}(t.children)}function f(l){e=[],n=[],t=(new Date).getTime();var u=s(function(n){var t,l=r.regLevel,u=r.invalidLine,a=n.split("\n"),s=0,f=0,h=[],o=new i(-1),c=new i(0);o.addChild(c);var p=[],g="";h.push(c),p.push(s);for(var v=0,d=a.length;v<d;++v)if(!(g=a[v]).match(u)){if((s=(t=l.exec(g))?t[1].length:0)>f){var m=c;c=new i(s),m.addChild(c),h.push(c),p.push(s)}else if(s<f){for(var w=!1,E=p.length-1;E>=0;--E)if(p[E]==s){c=new i(s),h.push(c),p.push(s),null!=h[E].parent&&h[E].parent.addChild(c),w=!0;break}if(!w)return void e.push("Error: Invalid indentation at line "+v+": "+g)}c.lines.push(g.replace(r.trim,"")),f=s}return o}(function(e){var n,t=e.split("\n"),i=r.comment;for(var l in t)(n=t[l].match(i))&&void 0!==n[3]&&(t[l]=n[0].substr(0,n[0].length-n[3].length));return t.join("\n")}(l)));return t=(new Date).getTime()-t,u}var h=new RegExp("^(\\ufeff?(= yaml =|---)$([\\s\\S]*?)(?:\\2|\\.\\.\\.)$(?:\\n)?)","m");function o(e){var n=(e=e||"").split(/(\r?\n)/);return n[0]&&/= yaml =|---/.test(n[0])?function(e){var n=h.exec(e);if(!n)return{attributes:{},body:e};var t=n[n.length-1].replace(/^\s+|\s+$/g,""),r=f(t)||{},i=e.replace(n[0],"");return{attributes:r,body:i,frontmatter:t}}(e):{attributes:{},body:e}}$docsify.plugins=[].concat(function(e,n){e.beforeEach(function(e){var t=o(e),r=t.attributes,i=t.body;return n.frontmatter=r,i})},$docsify.plugins)}();
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
(function () {
|
||||
// From https://github.com/egoist/vue-ga/blob/master/src/index.js
|
||||
function appendScript () {
|
||||
function appendScript() {
|
||||
var script = document.createElement('script');
|
||||
script.async = true;
|
||||
script.src = 'https://www.google-analytics.com/analytics.js';
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function init (id) {
|
||||
function init(id) {
|
||||
appendScript();
|
||||
window.ga =
|
||||
window.ga ||
|
||||
@@ -18,7 +18,7 @@ function init (id) {
|
||||
window.ga('create', id, 'auto');
|
||||
}
|
||||
|
||||
function collect () {
|
||||
function collect() {
|
||||
if (!window.ga) {
|
||||
init($docsify.ga);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(function () {
|
||||
function install (hook, vm) {
|
||||
function install(hook) {
|
||||
var dom = Docsify.dom;
|
||||
|
||||
hook.mounted(function (_) {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
!function(){$docsify.plugins=[].concat(function(n,t){var i=Docsify.dom;n.mounted(function(n){var t=i.create("div");t.id="gitalk-container";var e=i.getNode("#main");t.style="width: "+e.clientWidth+"px; margin: 0 auto 20px;",i.appendTo(i.find(".content"),t);var o=i.create("script");o.textContent="gitalk.render('gitalk-container')",i.appendTo(i.body,o)})},$docsify.plugins)}();
|
||||
!function(){$docsify.plugins=[].concat(function(n){var t=Docsify.dom;n.mounted(function(n){var i=t.create("div");i.id="gitalk-container";var e=t.getNode("#main");i.style="width: "+e.clientWidth+"px; margin: 0 auto 20px;",t.appendTo(t.find(".content"),i);var o=t.create("script");o.textContent="gitalk.render('gitalk-container')",t.appendTo(t.body,o)})},$docsify.plugins)}();
|
||||
|
||||
+41
-33
@@ -2,23 +2,23 @@
|
||||
var INDEXS = {};
|
||||
var helper;
|
||||
|
||||
function escapeHtml (string) {
|
||||
function escapeHtml(string) {
|
||||
var entityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'\'': ''',
|
||||
'/': '/'
|
||||
};
|
||||
|
||||
return String(string).replace(/[&<>"'\/]/g, function (s) { return entityMap[s]; })
|
||||
return String(string).replace(/[&<>"'/]/g, function (s) { return entityMap[s]; })
|
||||
}
|
||||
|
||||
function getAllPaths (router) {
|
||||
function getAllPaths(router) {
|
||||
var paths = [];
|
||||
|
||||
helper.dom.findAll('a:not([data-nosearch])').map(function (node) {
|
||||
helper.dom.findAll('a:not([data-nosearch])').forEach(function (node) {
|
||||
var href = node.href;
|
||||
var originHref = node.getAttribute('href');
|
||||
var path = router.parse(href).path;
|
||||
@@ -35,12 +35,12 @@ function getAllPaths (router) {
|
||||
return paths
|
||||
}
|
||||
|
||||
function saveData (maxAge) {
|
||||
function saveData(maxAge) {
|
||||
localStorage.setItem('docsify.search.expires', Date.now() + maxAge);
|
||||
localStorage.setItem('docsify.search.index', JSON.stringify(INDEXS));
|
||||
}
|
||||
|
||||
function genIndex (path, content, router, depth) {
|
||||
function genIndex(path, content, router, depth) {
|
||||
if ( content === void 0 ) content = '';
|
||||
|
||||
var tokens = window.marked.lexer(content);
|
||||
@@ -50,18 +50,18 @@ function genIndex (path, content, router, depth) {
|
||||
|
||||
tokens.forEach(function (token) {
|
||||
if (token.type === 'heading' && token.depth <= depth) {
|
||||
slug = router.toURL(path, { id: slugify(token.text) });
|
||||
index[slug] = { slug: slug, title: token.text, body: '' };
|
||||
slug = router.toURL(path, {id: slugify(token.text)});
|
||||
index[slug] = {slug: slug, title: token.text, body: ''};
|
||||
} else {
|
||||
if (!slug) { return }
|
||||
if (!slug) {
|
||||
return
|
||||
}
|
||||
if (!index[slug]) {
|
||||
index[slug] = { slug: slug, title: '', body: '' };
|
||||
index[slug] = {slug: slug, title: '', body: ''};
|
||||
} else if (index[slug].body) {
|
||||
index[slug].body += '\n' + (token.text || '');
|
||||
} else {
|
||||
if (index[slug].body) {
|
||||
index[slug].body += '\n' + (token.text || '');
|
||||
} else {
|
||||
index[slug].body = token.text;
|
||||
}
|
||||
index[slug].body = token.text;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -73,7 +73,7 @@ function genIndex (path, content, router, depth) {
|
||||
* @param {String} query
|
||||
* @returns {Array}
|
||||
*/
|
||||
function search (query) {
|
||||
function search(query) {
|
||||
var matchingResults = [];
|
||||
var data = [];
|
||||
Object.keys(INDEXS).forEach(function (key) {
|
||||
@@ -81,7 +81,7 @@ function search (query) {
|
||||
});
|
||||
|
||||
query = query.trim();
|
||||
var keywords = query.split(/[\s\-\,\\/]+/);
|
||||
var keywords = query.split(/[\s\-,\\/]+/);
|
||||
if (keywords.length !== 1) {
|
||||
keywords = [].concat(query, keywords);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ function search (query) {
|
||||
var postUrl = post.slug || '';
|
||||
|
||||
if (postTitle && postContent) {
|
||||
keywords.forEach(function (keyword, i) {
|
||||
keywords.forEach(function (keyword) {
|
||||
// From https://github.com/sindresorhus/escape-string-regexp
|
||||
var regEx = new RegExp(
|
||||
keyword.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'),
|
||||
@@ -111,7 +111,9 @@ function search (query) {
|
||||
isMatch = false;
|
||||
} else {
|
||||
isMatch = true;
|
||||
if (indexContent < 0) { indexContent = 0; }
|
||||
if (indexContent < 0) {
|
||||
indexContent = 0;
|
||||
}
|
||||
|
||||
var start = 0;
|
||||
var end = 0;
|
||||
@@ -119,7 +121,9 @@ function search (query) {
|
||||
start = indexContent < 11 ? 0 : indexContent - 10;
|
||||
end = start === 0 ? 70 : indexContent + keyword.length + 60;
|
||||
|
||||
if (end > postContent.length) { end = postContent.length; }
|
||||
if (end > postContent.length) {
|
||||
end = postContent.length;
|
||||
}
|
||||
|
||||
var matchContent =
|
||||
'...' +
|
||||
@@ -149,7 +153,7 @@ function search (query) {
|
||||
return matchingResults
|
||||
}
|
||||
|
||||
function init$1 (config, vm) {
|
||||
function init$1(config, vm) {
|
||||
helper = Docsify;
|
||||
|
||||
var isAuto = config.paths === 'auto';
|
||||
@@ -168,7 +172,9 @@ function init$1 (config, vm) {
|
||||
var count = 0;
|
||||
|
||||
paths.forEach(function (path) {
|
||||
if (INDEXS[path]) { return count++ }
|
||||
if (INDEXS[path]) {
|
||||
return count++
|
||||
}
|
||||
|
||||
helper
|
||||
.get(vm.router.getFile(path), false, vm.config.requestHeaders)
|
||||
@@ -181,13 +187,13 @@ function init$1 (config, vm) {
|
||||
|
||||
var NO_DATA_TEXT = '';
|
||||
|
||||
function style () {
|
||||
function style() {
|
||||
var code = "\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 .input-wrap {\n display: flex;\n align-items: center;\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: 0 7px;\n line-height: 36px;\n font-size: 14px;\n}\n\n.search input::-webkit-search-decoration,\n.search input::-webkit-search-cancel-button,\n.search input {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n.search .clear-button {\n width: 36px;\n text-align: right;\n display: none;\n}\n\n.search .clear-button.show {\n display: block;\n}\n\n.search .clear-button svg {\n transform: scale(.5);\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.style(code);
|
||||
}
|
||||
|
||||
function tpl (opts, defaultValue) {
|
||||
function tpl(opts, defaultValue) {
|
||||
if ( defaultValue === void 0 ) defaultValue = '';
|
||||
|
||||
var html =
|
||||
@@ -199,7 +205,7 @@ function tpl (opts, defaultValue) {
|
||||
Docsify.dom.before(aside, el);
|
||||
}
|
||||
|
||||
function doSearch (value) {
|
||||
function doSearch(value) {
|
||||
var $search = Docsify.dom.find('div.search');
|
||||
var $panel = Docsify.dom.find($search, '.results-panel');
|
||||
var $clearBtn = Docsify.dom.find($search, '.clear-button');
|
||||
@@ -222,7 +228,7 @@ function doSearch (value) {
|
||||
$panel.innerHTML = html || ("<p class=\"empty\">" + NO_DATA_TEXT + "</p>");
|
||||
}
|
||||
|
||||
function bindEvents () {
|
||||
function bindEvents() {
|
||||
var $search = Docsify.dom.find('div.search');
|
||||
var $input = Docsify.dom.find($search, 'input');
|
||||
var $inputWrap = Docsify.dom.find($search, '.input-wrap');
|
||||
@@ -239,7 +245,7 @@ function bindEvents () {
|
||||
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
|
||||
});
|
||||
Docsify.dom.on($inputWrap, 'click', function (e) {
|
||||
// click input outside
|
||||
// Click input outside
|
||||
if (e.target.tagName !== 'INPUT') {
|
||||
$input.value = '';
|
||||
doSearch();
|
||||
@@ -247,10 +253,12 @@ function bindEvents () {
|
||||
});
|
||||
}
|
||||
|
||||
function updatePlaceholder (text, path) {
|
||||
function updatePlaceholder(text, path) {
|
||||
var $input = Docsify.dom.getNode('.search input[type="search"]');
|
||||
|
||||
if (!$input) { return }
|
||||
if (!$input) {
|
||||
return
|
||||
}
|
||||
if (typeof text === 'string') {
|
||||
$input.placeholder = text;
|
||||
} else {
|
||||
@@ -259,7 +267,7 @@ function updatePlaceholder (text, path) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateNoData (text, path) {
|
||||
function updateNoData(text, path) {
|
||||
if (typeof text === 'string') {
|
||||
NO_DATA_TEXT = text;
|
||||
} else {
|
||||
@@ -268,7 +276,7 @@ function updateNoData (text, path) {
|
||||
}
|
||||
}
|
||||
|
||||
function init (opts, vm) {
|
||||
function init(opts, vm) {
|
||||
var keywords = vm.router.parse().query.s;
|
||||
|
||||
style();
|
||||
@@ -277,7 +285,7 @@ function init (opts, vm) {
|
||||
keywords && setTimeout(function (_) { return doSearch(keywords); }, 500);
|
||||
}
|
||||
|
||||
function update (opts, vm) {
|
||||
function update(opts, vm) {
|
||||
updatePlaceholder(opts.placeholder, vm.route.path);
|
||||
updateNoData(opts.noData, vm.route.path);
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
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
+2470
-3445
File diff suppressed because it is too large
Load Diff
+27
-15
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify",
|
||||
"version": "4.6.2",
|
||||
"version": "4.7.0",
|
||||
"description": "A magical documentation generator.",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
@@ -14,6 +14,7 @@
|
||||
"url": "git+https://github.com/QingWei-Li/docsify.git"
|
||||
},
|
||||
"main": "lib/docsify.js",
|
||||
"unpkg": "lib/docsify.min.js",
|
||||
"files": [
|
||||
"lib",
|
||||
"src",
|
||||
@@ -21,42 +22,53 @@
|
||||
],
|
||||
"scripts": {
|
||||
"bootstrap": "npm i && lerna bootstrap && npm run build:ssr",
|
||||
"build": "rm -rf lib themes && node build/build && mkdir lib/themes && mkdir themes && node build/build-css && npm run build:ssr && node build/build-cover",
|
||||
"dev:build": "rm -rf lib themes && mkdir themes && node build/build --dev && node build/build-css --dev",
|
||||
"dev": "node app & nodemon -w src -e js,css --exec 'npm run dev:build'",
|
||||
"build:ssr": "node build/build-ssr",
|
||||
"test": "eslint {src,packages} --fix",
|
||||
"pub:next": "RELEASE_TAG=next sh build/release.sh",
|
||||
"serve": "node server",
|
||||
"serve:ssr": "cross-env SSR=1 node server",
|
||||
"dev": "run-p serve watch:*",
|
||||
"dev:ssr": "run-p serve:ssr watch:*",
|
||||
"lint": "eslint {src,packages} --fix",
|
||||
"test": "run-p lint",
|
||||
"css": "stylus src/themes/*.styl -u autoprefixer-stylus",
|
||||
"watch:css": "run-p 'css -- -o themes -w'",
|
||||
"watch:js": "node build/build.js",
|
||||
"build:css:min": "mkdir lib/themes && run-p 'css -- -o lib/themes' && node build/mincss.js",
|
||||
"build:css": "mkdir themes && run-p 'css -- -o themes'",
|
||||
"build:js": "cross-env NODE_ENV=production node build/build.js",
|
||||
"build:ssr": "node build/ssr.js",
|
||||
"build:cover": "node build/cover.js",
|
||||
"build": "rimraf lib themes && run-s build:js build:css build:css:min build:ssr build:cover",
|
||||
"pub:next": "cross-env RELEASE_TAG=next sh build/release.sh",
|
||||
"pub": "sh build/release.sh",
|
||||
"postinstall": "opencollective postinstall"
|
||||
},
|
||||
"dependencies": {
|
||||
"marked": "^0.3.12",
|
||||
"medium-zoom": "^0.4.0",
|
||||
"opencollective": "^1.0.3",
|
||||
"medium-zoom": "^0.3.0",
|
||||
"prismjs": "^1.9.0",
|
||||
"tinydate": "^1.0.0",
|
||||
"tweezer.js": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer-stylus": "^0.14.0",
|
||||
"chokidar": "^2.0.2",
|
||||
"conventional-changelog-cli": "^1.3.5",
|
||||
"cross-env": "^5.1.3",
|
||||
"cssnano": "^3.10.0",
|
||||
"eslint": "^4.14.0",
|
||||
"eslint-config-vue": "^2.0.2",
|
||||
"eslint-plugin-vue": "^4.0.1",
|
||||
"eslint-config-xo-space": "^0.18.0",
|
||||
"lerna": "^2.5.1",
|
||||
"nodemon": "^1.14.7",
|
||||
"postcss": "^5.2.16",
|
||||
"postcss-salad": "^1.0.8",
|
||||
"live-server": "^1.2.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"rimraf": "^2.6.2",
|
||||
"rollup": "^0.53.3",
|
||||
"rollup-plugin-async": "^1.2.0",
|
||||
"rollup-plugin-buble": "^0.18.0",
|
||||
"rollup-plugin-commonjs": "^8.2.6",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"rollup-plugin-replace": "^2.0.0",
|
||||
"rollup-plugin-string": "^2.0.2",
|
||||
"rollup-plugin-uglify": "^2.0.1",
|
||||
"serve-static": "^1.13.1"
|
||||
"stylus": "^0.54.5"
|
||||
},
|
||||
"keywords": [
|
||||
"doc",
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import * as tpl from '../../src/core/render/tpl'
|
||||
import fetch from 'node-fetch'
|
||||
import { AbstractHistory } from '../../src/core/router/history/abstract'
|
||||
import { Compiler } from '../../src/core/render/compiler'
|
||||
import { isAbsolutePath } from '../../src/core/router/util'
|
||||
import { readFileSync } from 'fs'
|
||||
import { resolve, basename } from 'path'
|
||||
import {AbstractHistory} from '../../src/core/router/history/abstract'
|
||||
import {Compiler} from '../../src/core/render/compiler'
|
||||
import {isAbsolutePath} from '../../src/core/router/util'
|
||||
import {readFileSync} from 'fs'
|
||||
import {resolve, basename} from 'path'
|
||||
import resolvePathname from 'resolve-pathname'
|
||||
import debug from 'debug'
|
||||
import { prerenderEmbed } from '../../src/core/render/embed'
|
||||
import {prerenderEmbed} from '../../src/core/render/embed'
|
||||
|
||||
function cwd (...args) {
|
||||
function cwd(...args) {
|
||||
return resolve(process.cwd(), ...args)
|
||||
}
|
||||
|
||||
function mainTpl (config) {
|
||||
function mainTpl(config) {
|
||||
let html = `<nav class="app-nav${
|
||||
config.repo ? '' : ' no-badge'
|
||||
}"><!--navbar--></nav>`
|
||||
@@ -31,7 +31,7 @@ function mainTpl (config) {
|
||||
}
|
||||
|
||||
export default class Renderer {
|
||||
constructor ({ template, config, cache }) {
|
||||
constructor({template, config, cache}) {
|
||||
this.html = template
|
||||
this.config = config = Object.assign({}, config, {
|
||||
routerMode: 'history'
|
||||
@@ -51,15 +51,15 @@ export default class Renderer {
|
||||
this.template = this.html
|
||||
}
|
||||
|
||||
_getPath (url) {
|
||||
_getPath(url) {
|
||||
const file = this.router.getFile(url)
|
||||
|
||||
return isAbsolutePath(file) ? file : cwd(`./${file}`)
|
||||
}
|
||||
|
||||
async renderToString (url) {
|
||||
async renderToString(url) {
|
||||
this.url = url = this.router.parse(url).path
|
||||
const { loadSidebar, loadNavbar, coverpage } = this.config
|
||||
const {loadSidebar, loadNavbar, coverpage} = this.config
|
||||
|
||||
const mainFile = this._getPath(url)
|
||||
this._renderHtml('main', await this._render(mainFile, 'main'))
|
||||
@@ -100,15 +100,16 @@ export default class Renderer {
|
||||
return html
|
||||
}
|
||||
|
||||
_renderHtml (match, content) {
|
||||
_renderHtml(match, content) {
|
||||
this.html = this.html.replace(new RegExp(`<!--${match}-->`, 'g'), content)
|
||||
|
||||
return this.html
|
||||
}
|
||||
|
||||
async _render (path, type) {
|
||||
async _render(path, type) {
|
||||
let html = await this._loadFile(path)
|
||||
const { subMaxLevel, maxLevel } = this.config
|
||||
const {subMaxLevel, maxLevel} = this.config
|
||||
let tokens
|
||||
|
||||
switch (type) {
|
||||
case 'sidebar':
|
||||
@@ -122,7 +123,7 @@ export default class Renderer {
|
||||
html = this.compiler.cover(html)
|
||||
break
|
||||
case 'main':
|
||||
const tokens = await new Promise(r => {
|
||||
tokens = await new Promise(r => {
|
||||
prerenderEmbed(
|
||||
{
|
||||
fetch: url => this._loadFile(this._getPath(url)),
|
||||
@@ -144,13 +145,15 @@ export default class Renderer {
|
||||
return html
|
||||
}
|
||||
|
||||
async _loadFile (filePath) {
|
||||
async _loadFile(filePath) {
|
||||
debug('docsify')(`load > ${filePath}`)
|
||||
let content
|
||||
try {
|
||||
if (isAbsolutePath(filePath)) {
|
||||
const res = await fetch(filePath)
|
||||
if (!res.ok) throw Error()
|
||||
if (!res.ok) {
|
||||
throw Error()
|
||||
}
|
||||
content = await res.text()
|
||||
this.lock = 0
|
||||
} else {
|
||||
@@ -166,8 +169,11 @@ export default class Renderer {
|
||||
}
|
||||
|
||||
const fileName = basename(filePath)
|
||||
const result = await this._loadFile(
|
||||
resolvePathname(`../${fileName}`, filePath)
|
||||
)
|
||||
|
||||
return await this._loadFile(resolvePathname(`../${fileName}`, filePath))
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,5 +37,5 @@
|
||||
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
||||
}
|
||||
},
|
||||
"version": "4.6.2"
|
||||
"version": "4.7.0"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify-server-renderer",
|
||||
"version": "4.6.2",
|
||||
"version": "4.7.0",
|
||||
"description": "docsify server renderer",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
const liveServer = require('live-server')
|
||||
const isSSR = !!process.env.SSR
|
||||
const middleware = []
|
||||
|
||||
if (isSSR) {
|
||||
const Renderer = require('./packages/docsify-server-renderer/build.js')
|
||||
const renderer = new Renderer({
|
||||
template: `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>docsify</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<link rel="stylesheet" href="/themes/vue.css" title="vue">
|
||||
</head>
|
||||
<body>
|
||||
<!--inject-app-->
|
||||
<!--inject-config-->
|
||||
<script src="/lib/docsify.js"></script>
|
||||
</body>
|
||||
</html>`,
|
||||
config: {
|
||||
name: 'docsify',
|
||||
repo: 'qingwei-li/docsify',
|
||||
basePath: 'https://docsify.js.org/',
|
||||
loadNavbar: true,
|
||||
loadSidebar: true,
|
||||
subMaxLevel: 3,
|
||||
auto2top: true,
|
||||
alias: {
|
||||
'/de-de/changelog': '/changelog',
|
||||
'/zh-cn/changelog': '/changelog',
|
||||
'/changelog':
|
||||
'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||
}
|
||||
},
|
||||
path: './'
|
||||
})
|
||||
|
||||
middleware.push(function(req, res, next) {
|
||||
if (/\.(css|js)$/.test(req.url)) {
|
||||
return next()
|
||||
}
|
||||
renderer.renderToString(req.url).then(html => res.end(html))
|
||||
})
|
||||
}
|
||||
|
||||
const params = {
|
||||
port: 3000,
|
||||
watch: ['lib', 'docs', 'themes'],
|
||||
middleware
|
||||
}
|
||||
|
||||
liveServer.start(params)
|
||||
+62
-48
@@ -1,56 +1,70 @@
|
||||
import { merge, hyphenate, isPrimitive } from './util/core'
|
||||
import {merge, hyphenate, isPrimitive, hasOwn} from './util/core'
|
||||
|
||||
const config = merge(
|
||||
{
|
||||
el: '#app',
|
||||
repo: '',
|
||||
maxLevel: 6,
|
||||
subMaxLevel: 0,
|
||||
loadSidebar: null,
|
||||
loadNavbar: null,
|
||||
homepage: 'README.md',
|
||||
coverpage: '',
|
||||
basePath: '',
|
||||
auto2top: false,
|
||||
name: '',
|
||||
themeColor: '',
|
||||
nameLink: window.location.pathname,
|
||||
autoHeader: false,
|
||||
executeScript: null,
|
||||
noEmoji: false,
|
||||
ga: '',
|
||||
ext: '.md',
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: []
|
||||
},
|
||||
window.$docsify
|
||||
)
|
||||
export default function () {
|
||||
const config = merge(
|
||||
{
|
||||
el: '#app',
|
||||
repo: '',
|
||||
maxLevel: 6,
|
||||
subMaxLevel: 0,
|
||||
loadSidebar: null,
|
||||
loadNavbar: null,
|
||||
homepage: 'README.md',
|
||||
coverpage: '',
|
||||
basePath: '',
|
||||
auto2top: false,
|
||||
name: '',
|
||||
themeColor: '',
|
||||
nameLink: window.location.pathname,
|
||||
autoHeader: false,
|
||||
executeScript: null,
|
||||
noEmoji: false,
|
||||
ga: '',
|
||||
ext: '.md',
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: []
|
||||
},
|
||||
window.$docsify
|
||||
)
|
||||
|
||||
const script =
|
||||
document.currentScript ||
|
||||
[].slice
|
||||
.call(document.getElementsByTagName('script'))
|
||||
.filter(n => /docsify\./.test(n.src))[0]
|
||||
const script =
|
||||
document.currentScript ||
|
||||
[].slice
|
||||
.call(document.getElementsByTagName('script'))
|
||||
.filter(n => /docsify\./.test(n.src))[0]
|
||||
|
||||
if (script) {
|
||||
for (const prop in config) {
|
||||
const val = script.getAttribute('data-' + hyphenate(prop))
|
||||
if (script) {
|
||||
for (const prop in config) {
|
||||
if (hasOwn.call(config, prop)) {
|
||||
const val = script.getAttribute('data-' + hyphenate(prop))
|
||||
|
||||
if (isPrimitive(val)) {
|
||||
config[prop] = val === '' ? true : val
|
||||
if (isPrimitive(val)) {
|
||||
config[prop] = val === '' ? true : val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.loadSidebar === true) {
|
||||
config.loadSidebar = '_sidebar' + config.ext
|
||||
}
|
||||
if (config.loadNavbar === true) {
|
||||
config.loadNavbar = '_navbar' + config.ext
|
||||
}
|
||||
if (config.coverpage === true) {
|
||||
config.coverpage = '_coverpage' + config.ext
|
||||
}
|
||||
if (config.repo === true) {
|
||||
config.repo = ''
|
||||
}
|
||||
if (config.name === true) {
|
||||
config.name = ''
|
||||
}
|
||||
}
|
||||
|
||||
if (config.loadSidebar === true) config.loadSidebar = '_sidebar' + config.ext
|
||||
if (config.loadNavbar === true) config.loadNavbar = '_navbar' + config.ext
|
||||
if (config.coverpage === true) config.coverpage = '_coverpage' + config.ext
|
||||
if (config.repo === true) config.repo = ''
|
||||
if (config.name === true) config.name = ''
|
||||
window.$docsify = config
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
window.$docsify = config
|
||||
|
||||
export default config
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import { isMobile } from '../util/env'
|
||||
import { body, on } from '../util/dom'
|
||||
import {isMobile} from '../util/env'
|
||||
import {body, on} from '../util/dom'
|
||||
import * as sidebar from './sidebar'
|
||||
import { scrollIntoView } from './scroll'
|
||||
import {scrollIntoView} from './scroll'
|
||||
|
||||
export function eventMixin (proto) {
|
||||
export function eventMixin(proto) {
|
||||
proto.$resetEvents = function () {
|
||||
scrollIntoView(this.route.path, this.route.query.id)
|
||||
sidebar.getAndActive(this.router, 'nav')
|
||||
|
||||
if (this.config.loadNavbar) {
|
||||
sidebar.getAndActive(this.router, 'nav')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function initEvent (vm) {
|
||||
export function initEvent(vm) {
|
||||
// Bind toggle button
|
||||
sidebar.btn('button.sidebar-toggle', vm.router)
|
||||
sidebar.collapse('.sidebar', vm.router)
|
||||
|
||||
+40
-20
@@ -1,4 +1,4 @@
|
||||
import { isMobile } from '../util/env'
|
||||
import {isMobile} from '../util/env'
|
||||
import * as dom from '../util/dom'
|
||||
import Tweezer from 'tweezer.js'
|
||||
|
||||
@@ -8,8 +8,10 @@ let scroller = null
|
||||
let enableScrollEvent = true
|
||||
let coverHeight = 0
|
||||
|
||||
function scrollTo (el) {
|
||||
if (scroller) scroller.stop()
|
||||
function scrollTo(el) {
|
||||
if (scroller) {
|
||||
scroller.stop()
|
||||
}
|
||||
enableScrollEvent = false
|
||||
scroller = new Tweezer({
|
||||
start: window.pageYOffset,
|
||||
@@ -24,8 +26,10 @@ function scrollTo (el) {
|
||||
.begin()
|
||||
}
|
||||
|
||||
function highlight (path) {
|
||||
if (!enableScrollEvent) return
|
||||
function highlight(path) {
|
||||
if (!enableScrollEvent) {
|
||||
return
|
||||
}
|
||||
const sidebar = dom.getNode('.sidebar')
|
||||
const anchors = dom.findAll('.anchor')
|
||||
const wrap = dom.find(sidebar, '.sidebar-nav')
|
||||
@@ -38,22 +42,28 @@ function highlight (path) {
|
||||
const node = anchors[i]
|
||||
|
||||
if (node.offsetTop > top) {
|
||||
if (!last) last = node
|
||||
if (!last) {
|
||||
last = node
|
||||
}
|
||||
break
|
||||
} else {
|
||||
last = node
|
||||
}
|
||||
}
|
||||
if (!last) return
|
||||
const li = nav[getNavKey(path, last.getAttribute('data-id'))]
|
||||
if (!last) {
|
||||
return
|
||||
}
|
||||
const li = nav[getNavKey(decodeURIComponent(path), last.getAttribute('data-id'))]
|
||||
|
||||
if (!li || li === active) return
|
||||
if (!li || li === active) {
|
||||
return
|
||||
}
|
||||
|
||||
active && active.classList.remove('active')
|
||||
li.classList.add('active')
|
||||
active = li
|
||||
|
||||
// scroll into view
|
||||
// Scroll into view
|
||||
// https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297
|
||||
if (!hoverOver && dom.body.classList.contains('sticky')) {
|
||||
const height = sidebar.clientHeight
|
||||
@@ -68,11 +78,11 @@ function highlight (path) {
|
||||
}
|
||||
}
|
||||
|
||||
function getNavKey (path, id) {
|
||||
function getNavKey(path, id) {
|
||||
return `${path}?id=${id}`
|
||||
}
|
||||
|
||||
export function scrollActiveSidebar (router) {
|
||||
export function scrollActiveSidebar(router) {
|
||||
const cover = dom.find('.cover.show')
|
||||
coverHeight = cover ? cover.offsetHeight : 0
|
||||
|
||||
@@ -82,18 +92,26 @@ export function scrollActiveSidebar (router) {
|
||||
for (let i = 0, len = lis.length; i < len; i += 1) {
|
||||
const li = lis[i]
|
||||
const a = li.querySelector('a')
|
||||
if (!a) continue
|
||||
if (!a) {
|
||||
continue
|
||||
}
|
||||
let href = a.getAttribute('href')
|
||||
|
||||
if (href !== '/') {
|
||||
const { query: { id }, path } = router.parse(href)
|
||||
if (id) href = getNavKey(path, id)
|
||||
const {query: {id}, path} = router.parse(href)
|
||||
if (id) {
|
||||
href = getNavKey(path, id)
|
||||
}
|
||||
}
|
||||
|
||||
if (href) nav[decodeURIComponent(href)] = li
|
||||
if (href) {
|
||||
nav[decodeURIComponent(href)] = li
|
||||
}
|
||||
}
|
||||
|
||||
if (isMobile) return
|
||||
if (isMobile) {
|
||||
return
|
||||
}
|
||||
const path = router.getCurrentPath()
|
||||
dom.off('scroll', () => highlight(path))
|
||||
dom.on('scroll', () => highlight(path))
|
||||
@@ -105,8 +123,10 @@ export function scrollActiveSidebar (router) {
|
||||
})
|
||||
}
|
||||
|
||||
export function scrollIntoView (path, id) {
|
||||
if (!id) return
|
||||
export function scrollIntoView(path, id) {
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
|
||||
const section = dom.find('#' + id)
|
||||
section && scrollTo(section)
|
||||
@@ -120,6 +140,6 @@ export function scrollIntoView (path, id) {
|
||||
|
||||
const scrollEl = dom.$.scrollingElement || dom.$.documentElement
|
||||
|
||||
export function scroll2Top (offset = 0) {
|
||||
export function scroll2Top(offset = 0) {
|
||||
scrollEl.scrollTop = offset === true ? 0 : Number(offset)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { isMobile } from '../util/env'
|
||||
import {isMobile} from '../util/env'
|
||||
import * as dom from '../util/dom'
|
||||
|
||||
const title = dom.$.title
|
||||
/**
|
||||
* Toggle button
|
||||
*/
|
||||
export function btn (el, router) {
|
||||
export function btn(el) {
|
||||
const toggle = _ => dom.body.classList.toggle('close')
|
||||
|
||||
el = dom.getNode(el)
|
||||
@@ -22,10 +22,10 @@ export function btn (el, router) {
|
||||
)
|
||||
}
|
||||
|
||||
export function collapse (el, router) {
|
||||
export function collapse(el) {
|
||||
el = dom.getNode(el)
|
||||
|
||||
dom.on(el, 'click', ({ target }) => {
|
||||
dom.on(el, 'click', ({target}) => {
|
||||
if (
|
||||
target.nodeName === 'A' &&
|
||||
target.nextSibling &&
|
||||
@@ -36,9 +36,11 @@ export function collapse (el, router) {
|
||||
})
|
||||
}
|
||||
|
||||
export function sticky () {
|
||||
export function sticky() {
|
||||
const cover = dom.getNode('section.cover')
|
||||
if (!cover) return
|
||||
if (!cover) {
|
||||
return
|
||||
}
|
||||
const coverHeight = cover.getBoundingClientRect().height
|
||||
|
||||
if (window.pageYOffset >= coverHeight || cover.classList.contains('hidden')) {
|
||||
@@ -56,7 +58,7 @@ export function sticky () {
|
||||
* @param {Boolean} autoTitle auto set title
|
||||
* @return {element}
|
||||
*/
|
||||
export function getAndActive (router, el, isParent, autoTitle) {
|
||||
export function getAndActive(router, el, isParent, autoTitle) {
|
||||
el = dom.getNode(el)
|
||||
|
||||
const links = dom.findAll(el, 'a')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import progressbar from '../render/progressbar'
|
||||
import { noop } from '../util/core'
|
||||
import {noop, hasOwn} from '../util/core'
|
||||
|
||||
const cache = {}
|
||||
|
||||
@@ -9,7 +9,7 @@ const cache = {}
|
||||
* @param {boolean} [hasBar=false] has progress bar
|
||||
* @return { then(resolve, reject), abort }
|
||||
*/
|
||||
export function get (url, hasBar = false, headers = {}) {
|
||||
export function get(url, hasBar = false, headers = {}) {
|
||||
const xhr = new XMLHttpRequest()
|
||||
const on = function () {
|
||||
xhr.addEventListener.apply(xhr, arguments)
|
||||
@@ -17,12 +17,14 @@ export function get (url, hasBar = false, headers = {}) {
|
||||
const cached = cache[url]
|
||||
|
||||
if (cached) {
|
||||
return { then: cb => cb(cached.content, cached.opt), abort: noop }
|
||||
return {then: cb => cb(cached.content, cached.opt), abort: noop}
|
||||
}
|
||||
|
||||
xhr.open('GET', url)
|
||||
for (const i in headers) {
|
||||
xhr.setRequestHeader(i, headers[i])
|
||||
if (hasOwn.call(headers, i)) {
|
||||
xhr.setRequestHeader(i, headers[i])
|
||||
}
|
||||
}
|
||||
xhr.send()
|
||||
|
||||
@@ -45,7 +47,7 @@ export function get (url, hasBar = false, headers = {}) {
|
||||
}
|
||||
|
||||
on('error', error)
|
||||
on('load', ({ target }) => {
|
||||
on('load', ({target}) => {
|
||||
if (target.status >= 400) {
|
||||
error(target)
|
||||
} else {
|
||||
|
||||
+128
-30
@@ -1,14 +1,16 @@
|
||||
import { get } from './ajax'
|
||||
import { callHook } from '../init/lifecycle'
|
||||
import { getParentPath, stringifyQuery } from '../router/util'
|
||||
import { noop } from '../util/core'
|
||||
import { getAndActive } from '../event/sidebar'
|
||||
import {get} from './ajax'
|
||||
import {callHook} from '../init/lifecycle'
|
||||
import {getParentPath, stringifyQuery} from '../router/util'
|
||||
import {noop} from '../util/core'
|
||||
import {getAndActive} from '../event/sidebar'
|
||||
|
||||
function loadNested (path, qs, file, next, vm, first) {
|
||||
function loadNested(path, qs, file, next, vm, first) {
|
||||
path = first ? path : path.replace(/\/$/, '')
|
||||
path = getParentPath(path)
|
||||
|
||||
if (!path) return
|
||||
if (!path) {
|
||||
return
|
||||
}
|
||||
|
||||
get(
|
||||
vm.router.getFile(path + file) + qs,
|
||||
@@ -17,23 +19,50 @@ function loadNested (path, qs, file, next, vm, first) {
|
||||
).then(next, _ => loadNested(path, qs, file, next, vm))
|
||||
}
|
||||
|
||||
export function fetchMixin (proto) {
|
||||
export function fetchMixin(proto) {
|
||||
let last
|
||||
proto._fetch = function (cb = noop) {
|
||||
const { path, query } = this.route
|
||||
const qs = stringifyQuery(query, ['id'])
|
||||
const { loadNavbar, loadSidebar, requestHeaders } = this.config
|
||||
|
||||
// Abort last request
|
||||
last && last.abort && last.abort()
|
||||
const abort = () => last && last.abort && last.abort()
|
||||
const request = (url, hasbar, requestHeaders) => {
|
||||
abort()
|
||||
last = get(url, true, requestHeaders)
|
||||
return last
|
||||
}
|
||||
|
||||
last = get(this.router.getFile(path) + qs, true, requestHeaders)
|
||||
const get404Path = (path, config) => {
|
||||
const {notFoundPage, ext} = config
|
||||
const defaultPath = '_404' + (ext || '.md')
|
||||
let key
|
||||
let path404
|
||||
|
||||
// Current page is html
|
||||
this.isHTML = /\.html$/g.test(path)
|
||||
switch (typeof notFoundPage) {
|
||||
case 'boolean':
|
||||
path404 = defaultPath
|
||||
break
|
||||
case 'string':
|
||||
path404 = notFoundPage
|
||||
break
|
||||
|
||||
const loadSideAndNav = () => {
|
||||
if (!loadSidebar) return cb()
|
||||
case 'object':
|
||||
key = Object.keys(notFoundPage)
|
||||
.sort((a, b) => b.length - a.length)
|
||||
.find(key => path.match(new RegExp('^' + key)))
|
||||
|
||||
path404 = (key && notFoundPage[key]) || defaultPath
|
||||
break
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
return path404
|
||||
}
|
||||
|
||||
proto._loadSideAndNav = function (path, qs, loadSidebar, cb) {
|
||||
return () => {
|
||||
if (!loadSidebar) {
|
||||
return cb()
|
||||
}
|
||||
|
||||
const fn = result => {
|
||||
this._renderSidebar(result)
|
||||
@@ -43,14 +72,30 @@ export function fetchMixin (proto) {
|
||||
// Load sidebar
|
||||
loadNested(path, qs, loadSidebar, fn, this, true)
|
||||
}
|
||||
}
|
||||
|
||||
proto._fetch = function (cb = noop) {
|
||||
const {path, query} = this.route
|
||||
const qs = stringifyQuery(query, ['id'])
|
||||
const {loadNavbar, requestHeaders, loadSidebar} = this.config
|
||||
// Abort last request
|
||||
|
||||
const file = this.router.getFile(path)
|
||||
const req = request(file + qs, true, requestHeaders)
|
||||
|
||||
// Current page is html
|
||||
this.isHTML = /\.html$/g.test(file)
|
||||
|
||||
// Load main content
|
||||
last.then(
|
||||
(text, opt) => {
|
||||
this._renderMain(text, opt, loadSideAndNav)
|
||||
},
|
||||
req.then(
|
||||
(text, opt) =>
|
||||
this._renderMain(
|
||||
text,
|
||||
opt,
|
||||
this._loadSideAndNav(path, qs, loadSidebar, cb)
|
||||
),
|
||||
_ => {
|
||||
this._renderMain(null, {}, loadSideAndNav)
|
||||
this._fetchFallbackPage(file, qs, cb) || this._fetch404(file, qs, cb)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -67,7 +112,7 @@ export function fetchMixin (proto) {
|
||||
}
|
||||
|
||||
proto._fetchCover = function () {
|
||||
const { coverpage, requestHeaders } = this.config
|
||||
const {coverpage, requestHeaders} = this.config
|
||||
const query = this.route.query
|
||||
const root = getParentPath(this.route.path)
|
||||
|
||||
@@ -85,7 +130,7 @@ export function fetchMixin (proto) {
|
||||
path = cover === true ? '_coverpage' : cover
|
||||
}
|
||||
|
||||
const coverOnly = !!path && this.config.onlyCover
|
||||
const coverOnly = Boolean(path) && this.config.onlyCover
|
||||
if (path) {
|
||||
path = this.router.getFile(root + path)
|
||||
this.coverIsHTML = /\.html$/g.test(path)
|
||||
@@ -110,18 +155,71 @@ export function fetchMixin (proto) {
|
||||
if (onlyCover) {
|
||||
done()
|
||||
} else {
|
||||
this._fetch(result => {
|
||||
this._fetch(() => {
|
||||
this.$resetEvents()
|
||||
done()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
proto._fetchFallbackPage = function (path, qs, cb = noop) {
|
||||
const {requestHeaders, fallbackLanguages, loadSidebar} = this.config
|
||||
|
||||
if (!fallbackLanguages) {
|
||||
return false
|
||||
}
|
||||
|
||||
const local = path.split('/')[1]
|
||||
|
||||
if (fallbackLanguages.indexOf(local) === -1) {
|
||||
return false
|
||||
}
|
||||
const newPath = path.replace(new RegExp(`^/${local}`), '')
|
||||
const req = request(newPath + qs, true, requestHeaders)
|
||||
|
||||
req.then(
|
||||
(text, opt) =>
|
||||
this._renderMain(
|
||||
text,
|
||||
opt,
|
||||
this._loadSideAndNav(path, qs, loadSidebar, cb)
|
||||
),
|
||||
() => this._fetch404(path, qs, cb)
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
/**
|
||||
* Load the 404 page
|
||||
* @param path
|
||||
* @param qs
|
||||
* @param cb
|
||||
* @returns {*}
|
||||
* @private
|
||||
*/
|
||||
proto._fetch404 = function (path, qs, cb = noop) {
|
||||
const {loadSidebar, requestHeaders, notFoundPage} = this.config
|
||||
|
||||
const fnLoadSideAndNav = this._loadSideAndNav(path, qs, loadSidebar, cb)
|
||||
if (notFoundPage) {
|
||||
const path404 = get404Path(path, this.config)
|
||||
|
||||
request(this.router.getFile(path404), true, requestHeaders).then(
|
||||
(text, opt) => this._renderMain(text, opt, fnLoadSideAndNav),
|
||||
() => this._renderMain(null, {}, fnLoadSideAndNav)
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
this._renderMain(null, {}, fnLoadSideAndNav)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function initFetch (vm) {
|
||||
const { loadSidebar } = vm.config
|
||||
export function initFetch(vm) {
|
||||
const {loadSidebar} = vm.config
|
||||
|
||||
// server-client renderer
|
||||
// Server-Side Rendering
|
||||
if (vm.rendered) {
|
||||
const activeEl = getAndActive(vm.router, '.sidebar-nav', true, true)
|
||||
if (loadSidebar && activeEl) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import * as util from './util'
|
||||
import * as dom from './util/dom'
|
||||
import { Compiler } from './render/compiler'
|
||||
import { slugify } from './render/slugify'
|
||||
import { get } from './fetch/ajax'
|
||||
import {Compiler} from './render/compiler'
|
||||
import {slugify} from './render/slugify'
|
||||
import {get} from './fetch/ajax'
|
||||
import marked from 'marked'
|
||||
import prism from 'prismjs'
|
||||
|
||||
export default function () {
|
||||
window.Docsify = { util, dom, get, slugify }
|
||||
window.Docsify = {util, dom, get, slugify}
|
||||
window.DocsifyCompiler = Compiler
|
||||
window.marked = marked
|
||||
window.Prism = prism
|
||||
|
||||
+7
-7
@@ -1,14 +1,14 @@
|
||||
import { initMixin } from './init'
|
||||
import { routerMixin } from './router'
|
||||
import { renderMixin } from './render'
|
||||
import { fetchMixin } from './fetch'
|
||||
import { eventMixin } from './event'
|
||||
import {initMixin} from './init'
|
||||
import {routerMixin} from './router'
|
||||
import {renderMixin} from './render'
|
||||
import {fetchMixin} from './fetch'
|
||||
import {eventMixin} from './event'
|
||||
import initGlobalAPI from './global-api'
|
||||
|
||||
/**
|
||||
* Fork https://github.com/bendrucker/document-ready/blob/master/index.js
|
||||
*/
|
||||
function ready (callback) {
|
||||
function ready(callback) {
|
||||
const state = document.readyState
|
||||
|
||||
if (state === 'complete' || state === 'interactive') {
|
||||
@@ -18,7 +18,7 @@ function ready (callback) {
|
||||
document.addEventListener('DOMContentLoaded', callback)
|
||||
}
|
||||
|
||||
function Docsify () {
|
||||
function Docsify() {
|
||||
this._init()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import config from '../config'
|
||||
import { initLifecycle, callHook } from './lifecycle'
|
||||
import { initRender } from '../render'
|
||||
import { initRouter } from '../router'
|
||||
import { initEvent } from '../event'
|
||||
import { initFetch } from '../fetch'
|
||||
import { isFn } from '../util/core'
|
||||
import {initLifecycle, callHook} from './lifecycle'
|
||||
import {initRender} from '../render'
|
||||
import {initRouter} from '../router'
|
||||
import {initEvent} from '../event'
|
||||
import {initFetch} from '../fetch'
|
||||
import {isFn} from '../util/core'
|
||||
|
||||
export function initMixin (proto) {
|
||||
export function initMixin(proto) {
|
||||
proto._init = function () {
|
||||
const vm = this
|
||||
vm.config = config || {}
|
||||
vm.config = config()
|
||||
|
||||
initLifecycle(vm) // Init hooks
|
||||
initPlugin(vm) // Install plugins
|
||||
@@ -22,6 +22,6 @@ export function initMixin (proto) {
|
||||
}
|
||||
}
|
||||
|
||||
function initPlugin (vm) {
|
||||
function initPlugin(vm) {
|
||||
[].concat(vm.config.plugins).forEach(fn => isFn(fn) && fn(vm._lifecycle, vm))
|
||||
}
|
||||
|
||||
+12
-14
@@ -1,6 +1,6 @@
|
||||
import { noop } from '../util/core'
|
||||
import {noop} from '../util/core'
|
||||
|
||||
export function initLifecycle (vm) {
|
||||
export function initLifecycle(vm) {
|
||||
const hooks = [
|
||||
'init',
|
||||
'mounted',
|
||||
@@ -18,28 +18,26 @@ export function initLifecycle (vm) {
|
||||
})
|
||||
}
|
||||
|
||||
export function callHook (vm, hook, data, next = noop) {
|
||||
export function callHook(vm, hook, data, next = noop) {
|
||||
const queue = vm._hooks[hook]
|
||||
|
||||
const step = function (index) {
|
||||
const hook = queue[index]
|
||||
if (index >= queue.length) {
|
||||
next(data)
|
||||
} else {
|
||||
if (typeof hook === 'function') {
|
||||
if (hook.length === 2) {
|
||||
hook(data, result => {
|
||||
data = result
|
||||
step(index + 1)
|
||||
})
|
||||
} else {
|
||||
const result = hook(data)
|
||||
data = result !== undefined ? result : data
|
||||
} else if (typeof hook === 'function') {
|
||||
if (hook.length === 2) {
|
||||
hook(data, result => {
|
||||
data = result
|
||||
step(index + 1)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const result = hook(data)
|
||||
data = result === undefined ? data : result
|
||||
step(index + 1)
|
||||
}
|
||||
} else {
|
||||
step(index + 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+62
-40
@@ -1,15 +1,15 @@
|
||||
import marked from 'marked'
|
||||
import Prism from 'prismjs'
|
||||
import { helper as helperTpl, tree as treeTpl } from './tpl'
|
||||
import { genTree } from './gen-tree'
|
||||
import { slugify } from './slugify'
|
||||
import { emojify } from './emojify'
|
||||
import { isAbsolutePath, getPath } from '../router/util'
|
||||
import { isFn, merge, cached, isPrimitive } from '../util/core'
|
||||
import {helper as helperTpl, tree as treeTpl} from './tpl'
|
||||
import {genTree} from './gen-tree'
|
||||
import {slugify} from './slugify'
|
||||
import {emojify} from './emojify'
|
||||
import {isAbsolutePath, getPath, getParentPath} from '../router/util'
|
||||
import {isFn, merge, cached, isPrimitive} from '../util/core'
|
||||
|
||||
const cachedLinks = {}
|
||||
|
||||
export function getAndRemoveConfig (str = '') {
|
||||
export function getAndRemoveConfig(str = '') {
|
||||
const config = {}
|
||||
|
||||
if (str) {
|
||||
@@ -21,35 +21,37 @@ export function getAndRemoveConfig (str = '') {
|
||||
.trim()
|
||||
}
|
||||
|
||||
return { str, config }
|
||||
return {str, config}
|
||||
}
|
||||
|
||||
const compileMedia = {
|
||||
markdown (url) {
|
||||
markdown(url) {
|
||||
return {
|
||||
url
|
||||
}
|
||||
},
|
||||
iframe (url, title) {
|
||||
iframe(url, title) {
|
||||
return {
|
||||
code: `<iframe src="${url}" ${title || 'width=100% height=400'}></iframe>`
|
||||
}
|
||||
},
|
||||
video (url, title) {
|
||||
video(url, title) {
|
||||
return {
|
||||
code: `<video src="${url}" ${title || 'controls'}>Not Support</video>`
|
||||
}
|
||||
},
|
||||
audio (url, title) {
|
||||
audio(url, title) {
|
||||
return {
|
||||
code: `<audio src="${url}" ${title || 'controls'}>Not Support</audio>`
|
||||
}
|
||||
},
|
||||
code (url, title) {
|
||||
code(url, title) {
|
||||
let lang = url.match(/\.(\w+)$/)
|
||||
|
||||
lang = title || (lang && lang[1])
|
||||
if (lang === 'md') lang = 'markdown'
|
||||
if (lang === 'md') {
|
||||
lang = 'markdown'
|
||||
}
|
||||
|
||||
return {
|
||||
url,
|
||||
@@ -59,7 +61,7 @@ const compileMedia = {
|
||||
}
|
||||
|
||||
export class Compiler {
|
||||
constructor (config, router) {
|
||||
constructor(config, router) {
|
||||
this.config = config
|
||||
this.router = router
|
||||
this.cacheTree = {}
|
||||
@@ -86,7 +88,9 @@ export class Compiler {
|
||||
this.compile = cached(text => {
|
||||
let html = ''
|
||||
|
||||
if (!text) return text
|
||||
if (!text) {
|
||||
return text
|
||||
}
|
||||
|
||||
if (isPrimitive(text)) {
|
||||
html = compile(text)
|
||||
@@ -101,14 +105,18 @@ export class Compiler {
|
||||
})
|
||||
}
|
||||
|
||||
compileEmbed (href, title) {
|
||||
const { str, config } = getAndRemoveConfig(title)
|
||||
compileEmbed(href, title) {
|
||||
const {str, config} = getAndRemoveConfig(title)
|
||||
let embed
|
||||
title = str
|
||||
|
||||
if (config.include) {
|
||||
if (!isAbsolutePath(href)) {
|
||||
href = getPath(process.env.SSR ? '' : this.contentBase, href)
|
||||
href = getPath(
|
||||
process.env.SSR ? '' : this.contentBase,
|
||||
getParentPath(this.router.getCurrentPath()),
|
||||
href
|
||||
)
|
||||
}
|
||||
|
||||
let media
|
||||
@@ -134,7 +142,7 @@ export class Compiler {
|
||||
}
|
||||
}
|
||||
|
||||
_matchNotCompileLink (link) {
|
||||
_matchNotCompileLink(link) {
|
||||
const links = this.config.noCompileLinks || []
|
||||
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
@@ -147,18 +155,18 @@ export class Compiler {
|
||||
}
|
||||
}
|
||||
|
||||
_initRenderer () {
|
||||
_initRenderer() {
|
||||
const renderer = new marked.Renderer()
|
||||
const { linkTarget, router, contentBase } = this
|
||||
const {linkTarget, router, contentBase} = this
|
||||
const _self = this
|
||||
const origin = {}
|
||||
|
||||
/**
|
||||
* render anchor tag
|
||||
* Render anchor tag
|
||||
* @link https://github.com/chjj/marked#overriding-renderer-methods
|
||||
*/
|
||||
origin.heading = renderer.heading = function (text, level) {
|
||||
const nextToc = { level, title: text }
|
||||
const nextToc = {level, title: text}
|
||||
|
||||
if (/{docsify-ignore}/g.test(text)) {
|
||||
text = text.replace('{docsify-ignore}', '')
|
||||
@@ -173,13 +181,13 @@ export class Compiler {
|
||||
}
|
||||
|
||||
const slug = slugify(text)
|
||||
const url = router.toURL(router.getCurrentPath(), { id: slug })
|
||||
const url = router.toURL(router.getCurrentPath(), {id: slug})
|
||||
nextToc.slug = url
|
||||
_self.toc.push(nextToc)
|
||||
|
||||
return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${text}</span></a></h${level}>`
|
||||
}
|
||||
// highlight code
|
||||
// Highlight code
|
||||
origin.code = renderer.code = function (code, lang = '') {
|
||||
code = code.replace(/@DOCSIFY_QM@/g, '`')
|
||||
const hl = Prism.highlight(
|
||||
@@ -192,15 +200,17 @@ export class Compiler {
|
||||
origin.link = renderer.link = function (href, title = '', text) {
|
||||
let attrs = ''
|
||||
|
||||
const { str, config } = getAndRemoveConfig(title)
|
||||
const {str, config} = getAndRemoveConfig(title)
|
||||
title = str
|
||||
|
||||
if (
|
||||
!/:|(\/{2})/.test(href) &&
|
||||
!isAbsolutePath(href) &&
|
||||
!_self._matchNotCompileLink(href) &&
|
||||
!config.ignore
|
||||
) {
|
||||
if (href === _self.config.homepage) href = 'README'
|
||||
if (href === _self.config.homepage) {
|
||||
href = 'README'
|
||||
}
|
||||
href = router.toURL(href, null, router.getCurrentPath())
|
||||
} else {
|
||||
attrs += ` target="${linkTarget}"`
|
||||
@@ -222,18 +232,21 @@ export class Compiler {
|
||||
return `<a href="${href}"${attrs}>${text}</a>`
|
||||
}
|
||||
origin.paragraph = renderer.paragraph = function (text) {
|
||||
let result
|
||||
if (/^!>/.test(text)) {
|
||||
return helperTpl('tip', text)
|
||||
result = helperTpl('tip', text)
|
||||
} else if (/^\?>/.test(text)) {
|
||||
return helperTpl('warn', text)
|
||||
result = helperTpl('warn', text)
|
||||
} else {
|
||||
result = `<p>${text}</p>`
|
||||
}
|
||||
return `<p>${text}</p>`
|
||||
return result
|
||||
}
|
||||
origin.image = renderer.image = function (href, title, text) {
|
||||
let url = href
|
||||
let attrs = ''
|
||||
|
||||
const { str, config } = getAndRemoveConfig(title)
|
||||
const {str, config} = getAndRemoveConfig(title)
|
||||
title = str
|
||||
|
||||
if (config['no-zoom']) {
|
||||
@@ -244,8 +257,18 @@ export class Compiler {
|
||||
attrs += ` title="${title}"`
|
||||
}
|
||||
|
||||
const size = config.size
|
||||
if (size) {
|
||||
const sizes = size.split('x')
|
||||
if (sizes[1]) {
|
||||
attrs += 'width=' + sizes[0] + ' height=' + sizes[1]
|
||||
} else {
|
||||
attrs += 'width=' + sizes[0]
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAbsolutePath(href)) {
|
||||
url = getPath(contentBase, href)
|
||||
url = getPath(contentBase, getParentPath(router.getCurrentPath()), href)
|
||||
}
|
||||
|
||||
return `<img src="${url}"data-origin="${href}" alt="${text}"${attrs}>`
|
||||
@@ -271,13 +294,12 @@ export class Compiler {
|
||||
/**
|
||||
* Compile sidebar
|
||||
*/
|
||||
sidebar (text, level) {
|
||||
sidebar(text, level) {
|
||||
const currentPath = this.router.getCurrentPath()
|
||||
let html = ''
|
||||
|
||||
if (text) {
|
||||
html = this.compile(text)
|
||||
html = html && html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0]
|
||||
} else {
|
||||
const tree = this.cacheTree[currentPath] || genTree(this.toc, level)
|
||||
html = treeTpl(tree, '<ul>')
|
||||
@@ -290,13 +312,13 @@ export class Compiler {
|
||||
/**
|
||||
* Compile sub sidebar
|
||||
*/
|
||||
subSidebar (level) {
|
||||
subSidebar(level) {
|
||||
if (!level) {
|
||||
this.toc = []
|
||||
return
|
||||
}
|
||||
const currentPath = this.router.getCurrentPath()
|
||||
const { cacheTree, toc } = this
|
||||
const {cacheTree, toc} = this
|
||||
|
||||
toc[0] && toc[0].ignoreAllSubs && toc.splice(0)
|
||||
toc[0] && toc[0].level === 1 && toc.shift()
|
||||
@@ -312,14 +334,14 @@ export class Compiler {
|
||||
return treeTpl(tree, '<ul class="app-sub-sidebar">')
|
||||
}
|
||||
|
||||
article (text) {
|
||||
article(text) {
|
||||
return this.compile(text)
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile cover page
|
||||
*/
|
||||
cover (text) {
|
||||
cover(text) {
|
||||
const cacheToc = this.toc.slice()
|
||||
const html = this.compile(text)
|
||||
|
||||
|
||||
+36
-28
@@ -1,42 +1,50 @@
|
||||
import { get } from '../fetch/ajax'
|
||||
import { merge } from '../util/core'
|
||||
import {get} from '../fetch/ajax'
|
||||
import {merge} from '../util/core'
|
||||
|
||||
const cached = {}
|
||||
|
||||
function walkFetchEmbed ({ step = 0, embedTokens, compile, fetch }, cb) {
|
||||
const token = embedTokens[step]
|
||||
function walkFetchEmbed({embedTokens, compile, fetch}, cb) {
|
||||
let token
|
||||
let step = 0
|
||||
let count = 1
|
||||
|
||||
if (!token) {
|
||||
if (!embedTokens.length) {
|
||||
return cb({})
|
||||
}
|
||||
|
||||
const next = text => {
|
||||
let embedToken
|
||||
if (text) {
|
||||
if (token.embed.type === 'markdown') {
|
||||
embedToken = compile.lexer(text)
|
||||
} else if (token.embed.type === 'code') {
|
||||
embedToken = compile.lexer(
|
||||
'```' +
|
||||
token.embed.lang +
|
||||
'\n' +
|
||||
text.replace(/`/g, '@DOCSIFY_QM@') +
|
||||
'\n```\n'
|
||||
)
|
||||
while ((token = embedTokens[step++])) {
|
||||
const next = (function (token) {
|
||||
return text => {
|
||||
let embedToken
|
||||
if (text) {
|
||||
if (token.embed.type === 'markdown') {
|
||||
embedToken = compile.lexer(text)
|
||||
} else if (token.embed.type === 'code') {
|
||||
embedToken = compile.lexer(
|
||||
'```' +
|
||||
token.embed.lang +
|
||||
'\n' +
|
||||
text.replace(/`/g, '@DOCSIFY_QM@') +
|
||||
'\n```\n'
|
||||
)
|
||||
}
|
||||
}
|
||||
cb({token, embedToken})
|
||||
if (++count >= step) {
|
||||
cb({})
|
||||
}
|
||||
}
|
||||
}
|
||||
cb({ token, embedToken })
|
||||
walkFetchEmbed({ step: ++step, compile, embedTokens, fetch }, cb)
|
||||
}
|
||||
})(token)
|
||||
|
||||
if (process.env.SSR) {
|
||||
fetch(token.embed.url).then(next)
|
||||
} else {
|
||||
get(token.embed.url).then(next)
|
||||
if (process.env.SSR) {
|
||||
fetch(token.embed.url).then(next)
|
||||
} else {
|
||||
get(token.embed.url).then(next)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function prerenderEmbed ({ compiler, raw = '', fetch }, done) {
|
||||
export function prerenderEmbed({compiler, raw = '', fetch}, done) {
|
||||
let hit
|
||||
if ((hit = cached[raw])) {
|
||||
return done(hit)
|
||||
@@ -72,7 +80,7 @@ export function prerenderEmbed ({ compiler, raw = '', fetch }, done) {
|
||||
})
|
||||
|
||||
let moveIndex = 0
|
||||
walkFetchEmbed({ compile, embedTokens, fetch }, ({ embedToken, token }) => {
|
||||
walkFetchEmbed({compile, embedTokens, fetch}, ({embedToken, token}) => {
|
||||
if (token) {
|
||||
const index = token.index + moveIndex
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { inBrowser } from '../util/env'
|
||||
import {inBrowser} from '../util/env'
|
||||
|
||||
function replace (m, $1) {
|
||||
function replace(m, $1) {
|
||||
return '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' + $1 + '.png" alt="' + $1 + '" />'
|
||||
}
|
||||
|
||||
export function emojify (text) {
|
||||
export function emojify(text) {
|
||||
return text
|
||||
.replace(/<(pre|template|code)[^>]*?>[\s\S]+?<\/(pre|template|code)>/g, m => m.replace(/:/g, '__colon__'))
|
||||
.replace(/:(\w+?):/ig, (inBrowser && window.emojify) || replace)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* gen toc tree
|
||||
* Gen toc tree
|
||||
* @link https://github.com/killercup/grock/blob/5280ae63e16c5739e9233d9009bc235ed7d79a50/styles/solarized/assets/js/behavior.coffee#L54-L81
|
||||
* @param {Array} toc
|
||||
* @param {Number} maxLevel
|
||||
* @return {Array}
|
||||
*/
|
||||
export function genTree (toc, maxLevel) {
|
||||
export function genTree(toc, maxLevel) {
|
||||
const headlines = []
|
||||
const last = {}
|
||||
|
||||
@@ -13,7 +13,9 @@ export function genTree (toc, maxLevel) {
|
||||
const level = headline.level || 1
|
||||
const len = level - 1
|
||||
|
||||
if (level > maxLevel) return
|
||||
if (level > maxLevel) {
|
||||
return
|
||||
}
|
||||
if (last[len]) {
|
||||
last[len].children = (last[len].children || []).concat(headline)
|
||||
} else {
|
||||
|
||||
+51
-34
@@ -2,48 +2,53 @@ import * as dom from '../util/dom'
|
||||
import * as tpl from './tpl'
|
||||
import cssVars from '../util/polyfill/css-vars'
|
||||
import tinydate from 'tinydate'
|
||||
import { callHook } from '../init/lifecycle'
|
||||
import { Compiler } from './compiler'
|
||||
import { getAndActive, sticky } from '../event/sidebar'
|
||||
import { getPath, isAbsolutePath } from '../router/util'
|
||||
import { isMobile, inBrowser } from '../util/env'
|
||||
import { isPrimitive } from '../util/core'
|
||||
import { scrollActiveSidebar, scroll2Top } from '../event/scroll'
|
||||
import { prerenderEmbed } from './embed'
|
||||
import {callHook} from '../init/lifecycle'
|
||||
import {Compiler} from './compiler'
|
||||
import {getAndActive, sticky} from '../event/sidebar'
|
||||
import {getPath, isAbsolutePath} from '../router/util'
|
||||
import {isMobile, inBrowser} from '../util/env'
|
||||
import {isPrimitive} from '../util/core'
|
||||
import {scrollActiveSidebar, scroll2Top} from '../event/scroll'
|
||||
import {prerenderEmbed} from './embed'
|
||||
|
||||
function executeScript () {
|
||||
function executeScript() {
|
||||
const script = dom
|
||||
.findAll('.markdown-section>script')
|
||||
.filter(s => !/template/.test(s.type))[0]
|
||||
if (!script) return false
|
||||
if (!script) {
|
||||
return false
|
||||
}
|
||||
const code = script.innerText.trim()
|
||||
if (!code) return false
|
||||
if (!code) {
|
||||
return false
|
||||
}
|
||||
|
||||
setTimeout(_ => {
|
||||
window.__EXECUTE_RESULT__ = new Function(code)()
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function formatUpdated (html, updated, fn) {
|
||||
function formatUpdated(html, updated, fn) {
|
||||
updated =
|
||||
typeof fn === 'function'
|
||||
? fn(updated)
|
||||
: typeof fn === 'string' ? tinydate(fn)(new Date(updated)) : updated
|
||||
typeof fn === 'function' ?
|
||||
fn(updated) :
|
||||
typeof fn === 'string' ?
|
||||
tinydate(fn)(new Date(updated)) :
|
||||
updated
|
||||
|
||||
return html.replace(/{docsify-updated}/g, updated)
|
||||
}
|
||||
|
||||
function renderMain (html) {
|
||||
function renderMain(html) {
|
||||
if (!html) {
|
||||
// TODO: Custom 404 page
|
||||
html = 'not found'
|
||||
html = '<h1>404 - Not found</h1>'
|
||||
}
|
||||
|
||||
this._renderTo('.markdown-section', html)
|
||||
// Render sidebar with the TOC
|
||||
!this.config.loadSidebar && this._renderSidebar()
|
||||
|
||||
// execute script
|
||||
// Execute script
|
||||
if (
|
||||
this.config.executeScript !== false &&
|
||||
typeof window.Vue !== 'undefined' &&
|
||||
@@ -59,12 +64,14 @@ function renderMain (html) {
|
||||
}
|
||||
}
|
||||
|
||||
function renderNameLink (vm) {
|
||||
function renderNameLink(vm) {
|
||||
const el = dom.getNode('.app-name-link')
|
||||
const nameLink = vm.config.nameLink
|
||||
const path = vm.route.path
|
||||
|
||||
if (!el) return
|
||||
if (!el) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isPrimitive(vm.config.nameLink)) {
|
||||
el.setAttribute('href', nameLink)
|
||||
@@ -75,14 +82,16 @@ function renderNameLink (vm) {
|
||||
}
|
||||
}
|
||||
|
||||
export function renderMixin (proto) {
|
||||
export function renderMixin(proto) {
|
||||
proto._renderTo = function (el, content, replace) {
|
||||
const node = dom.getNode(el)
|
||||
if (node) node[replace ? 'outerHTML' : 'innerHTML'] = content
|
||||
if (node) {
|
||||
node[replace ? 'outerHTML' : 'innerHTML'] = content
|
||||
}
|
||||
}
|
||||
|
||||
proto._renderSidebar = function (text) {
|
||||
const { maxLevel, subMaxLevel, loadSidebar } = this.config
|
||||
const {maxLevel, subMaxLevel, loadSidebar} = this.config
|
||||
|
||||
this._renderTo('.sidebar-nav', this.compiler.sidebar(text, maxLevel))
|
||||
const activeEl = getAndActive(this.router, '.sidebar-nav', true, true)
|
||||
@@ -90,15 +99,15 @@ export function renderMixin (proto) {
|
||||
activeEl.parentNode.innerHTML +=
|
||||
this.compiler.subSidebar(subMaxLevel) || ''
|
||||
} else {
|
||||
// reset toc
|
||||
// Reset toc
|
||||
this.compiler.subSidebar()
|
||||
}
|
||||
// bind event
|
||||
// Bind event
|
||||
this._bindEventOnRendered(activeEl)
|
||||
}
|
||||
|
||||
proto._bindEventOnRendered = function (activeEl) {
|
||||
const { autoHeader, auto2top } = this.config
|
||||
const {autoHeader, auto2top} = this.config
|
||||
|
||||
scrollActiveSidebar(this.router)
|
||||
|
||||
@@ -117,7 +126,9 @@ export function renderMixin (proto) {
|
||||
|
||||
proto._renderNav = function (text) {
|
||||
text && this._renderTo('nav', this.compiler.compile(text))
|
||||
getAndActive(this.router, 'nav')
|
||||
if (this.config.loadNavbar) {
|
||||
getAndActive(this.router, 'nav')
|
||||
}
|
||||
}
|
||||
|
||||
proto._renderMain = function (text, opt = {}, next) {
|
||||
@@ -135,14 +146,14 @@ export function renderMixin (proto) {
|
||||
callHook(this, 'afterEach', html, text => renderMain.call(this, text))
|
||||
}
|
||||
if (this.isHTML) {
|
||||
html = this.result
|
||||
html = this.result = text
|
||||
callback()
|
||||
next()
|
||||
} else {
|
||||
prerenderEmbed(
|
||||
{
|
||||
compiler: this.compiler,
|
||||
raw: text
|
||||
raw: result
|
||||
},
|
||||
tokens => {
|
||||
html = this.compiler.compile(tokens)
|
||||
@@ -191,18 +202,18 @@ export function renderMixin (proto) {
|
||||
}
|
||||
|
||||
proto._updateRender = function () {
|
||||
// render name link
|
||||
// Render name link
|
||||
renderNameLink(this)
|
||||
}
|
||||
}
|
||||
|
||||
export function initRender (vm) {
|
||||
export function initRender(vm) {
|
||||
const config = vm.config
|
||||
|
||||
// Init markdown compiler
|
||||
vm.compiler = new Compiler(config, vm.router)
|
||||
if (inBrowser) {
|
||||
window['__current_docsify_compiler__'] = vm.compiler
|
||||
window.__current_docsify_compiler__ = vm.compiler
|
||||
}
|
||||
|
||||
const id = config.el || '#app'
|
||||
@@ -220,6 +231,10 @@ export function initRender (vm) {
|
||||
html += tpl.cover()
|
||||
}
|
||||
|
||||
if (config.logo) {
|
||||
config.logo = getPath(vm.router.getBasePath(), config.logo)
|
||||
}
|
||||
|
||||
html += tpl.main(config)
|
||||
// Render main app
|
||||
vm._renderTo(el, html, true)
|
||||
@@ -238,7 +253,9 @@ export function initRender (vm) {
|
||||
}
|
||||
|
||||
// Add nav
|
||||
dom.before(navAppendToTarget, navEl)
|
||||
if (config.loadNavbar) {
|
||||
dom.before(navAppendToTarget, navEl)
|
||||
}
|
||||
|
||||
if (config.themeColor) {
|
||||
dom.$.head.appendChild(
|
||||
|
||||
@@ -6,7 +6,7 @@ let timeId
|
||||
/**
|
||||
* Init progress component
|
||||
*/
|
||||
function init () {
|
||||
function init() {
|
||||
const div = dom.create('div')
|
||||
|
||||
div.classList.add('progress')
|
||||
@@ -16,7 +16,7 @@ function init () {
|
||||
/**
|
||||
* Render progress bar
|
||||
*/
|
||||
export default function ({ loaded, total, step }) {
|
||||
export default function ({loaded, total, step}) {
|
||||
let num
|
||||
|
||||
!barEl && init()
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
let cache = {}
|
||||
const re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g
|
||||
import {hasOwn} from '../util/core'
|
||||
|
||||
function lower (string) {
|
||||
let cache = {}
|
||||
const re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g
|
||||
|
||||
function lower(string) {
|
||||
return string.toLowerCase()
|
||||
}
|
||||
|
||||
export function slugify (str) {
|
||||
if (typeof str !== 'string') return ''
|
||||
export function slugify(str) {
|
||||
if (typeof str !== 'string') {
|
||||
return ''
|
||||
}
|
||||
|
||||
let slug = str
|
||||
.trim()
|
||||
@@ -18,7 +22,7 @@ export function slugify (str) {
|
||||
.replace(/^(\d)/, '_$1')
|
||||
let count = cache[slug]
|
||||
|
||||
count = cache.hasOwnProperty(slug) ? count + 1 : 0
|
||||
count = hasOwn.call(cache, slug) ? count + 1 : 0
|
||||
cache[slug] = count
|
||||
|
||||
if (count) {
|
||||
|
||||
+23
-13
@@ -1,12 +1,16 @@
|
||||
import { isMobile } from '../util/env'
|
||||
import {isMobile} from '../util/env'
|
||||
/**
|
||||
* Render github corner
|
||||
* @param {Object} data
|
||||
* @return {String}
|
||||
*/
|
||||
export function corner (data) {
|
||||
if (!data) return ''
|
||||
if (!/\/\//.test(data)) data = 'https://github.com/' + data
|
||||
export function corner(data) {
|
||||
if (!data) {
|
||||
return ''
|
||||
}
|
||||
if (!/\/\//.test(data)) {
|
||||
data = 'https://github.com/' + data
|
||||
}
|
||||
data = data.replace(/^git\+/, '')
|
||||
|
||||
return (
|
||||
@@ -23,7 +27,7 @@ export function corner (data) {
|
||||
/**
|
||||
* Render main content
|
||||
*/
|
||||
export function main (config) {
|
||||
export function main(config) {
|
||||
const aside =
|
||||
'<button class="sidebar-toggle">' +
|
||||
'<div class="sidebar-toggle-button">' +
|
||||
@@ -31,9 +35,13 @@ export function main (config) {
|
||||
'</div>' +
|
||||
'</button>' +
|
||||
'<aside class="sidebar">' +
|
||||
(config.name
|
||||
? `<h1><a class="app-name-link" data-nosearch>${config.name}</a></h1>`
|
||||
: '') +
|
||||
(config.name ?
|
||||
`<h1><a class="app-name-link" data-nosearch>${
|
||||
config.logo ?
|
||||
`<img alt=${config.name} src=${config.logo}>` :
|
||||
config.name
|
||||
}</a></h1>` :
|
||||
'') +
|
||||
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
||||
'</aside>'
|
||||
|
||||
@@ -49,7 +57,7 @@ export function main (config) {
|
||||
/**
|
||||
* Cover Page
|
||||
*/
|
||||
export function cover () {
|
||||
export function cover() {
|
||||
const SL = ', 100%, 85%'
|
||||
const bgc =
|
||||
'linear-gradient(to left bottom, ' +
|
||||
@@ -70,8 +78,10 @@ export function cover () {
|
||||
* @param {String} tpl
|
||||
* @return {String}
|
||||
*/
|
||||
export function tree (toc, tpl = '') {
|
||||
if (!toc || !toc.length) return ''
|
||||
export function tree(toc, tpl = '') {
|
||||
if (!toc || !toc.length) {
|
||||
return ''
|
||||
}
|
||||
|
||||
toc.forEach(node => {
|
||||
tpl += `<li><a class="section-link" href="${node.slug}">${
|
||||
@@ -85,10 +95,10 @@ export function tree (toc, tpl = '') {
|
||||
return tpl
|
||||
}
|
||||
|
||||
export function helper (className, content) {
|
||||
export function helper(className, content) {
|
||||
return `<p class="${className}">${content.slice(5).trim()}</p>`
|
||||
}
|
||||
|
||||
export function theme (color) {
|
||||
export function theme(color) {
|
||||
return `<style>:root{--theme-color: ${color};}</style>`
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { History } from './base'
|
||||
import { parseQuery } from '../util'
|
||||
import {History} from './base'
|
||||
import {parseQuery} from '../util'
|
||||
|
||||
export class AbstractHistory extends History {
|
||||
constructor (config) {
|
||||
constructor(config) {
|
||||
super(config)
|
||||
this.mode = 'abstract'
|
||||
}
|
||||
|
||||
parse (path) {
|
||||
parse(path) {
|
||||
let query = ''
|
||||
|
||||
const queryIndex = path.indexOf('?')
|
||||
|
||||
@@ -5,40 +5,40 @@ import {
|
||||
cleanPath,
|
||||
replaceSlug
|
||||
} from '../util'
|
||||
import { noop, merge } from '../../util/core'
|
||||
import {noop, merge} from '../../util/core'
|
||||
|
||||
const cached = {}
|
||||
|
||||
function getAlias (path, alias, last) {
|
||||
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
|
||||
return match ?
|
||||
getAlias(path.replace(cached[match], alias[match]), alias, path) :
|
||||
path
|
||||
}
|
||||
|
||||
function getFileName (path, ext) {
|
||||
return new RegExp(`\\.(${ext.replace(/^\./, '')}|html)$`, 'g').test(path)
|
||||
? path
|
||||
: /\/$/g.test(path) ? `${path}README${ext}` : `${path}${ext}`
|
||||
function getFileName(path, ext) {
|
||||
return new RegExp(`\\.(${ext.replace(/^\./, '')}|html)$`, 'g').test(path) ?
|
||||
path :
|
||||
/\/$/g.test(path) ? `${path}README${ext}` : `${path}${ext}`
|
||||
}
|
||||
|
||||
export class History {
|
||||
constructor (config) {
|
||||
constructor(config) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
getBasePath () {
|
||||
getBasePath() {
|
||||
return this.config.basePath
|
||||
}
|
||||
|
||||
getFile (path = this.getCurrentPath(), isRelative) {
|
||||
const { config } = this
|
||||
getFile(path = this.getCurrentPath(), isRelative) {
|
||||
const {config} = this
|
||||
const base = this.getBasePath()
|
||||
const ext = typeof config.ext !== 'string' ? '.md' : config.ext
|
||||
const ext = typeof config.ext === 'string' ? config.ext : '.md'
|
||||
|
||||
path = config.alias ? getAlias(path, config.alias) : path
|
||||
path = getFileName(path, ext)
|
||||
@@ -52,17 +52,17 @@ export class History {
|
||||
return path
|
||||
}
|
||||
|
||||
onchange (cb = noop) {
|
||||
onchange(cb = noop) {
|
||||
cb()
|
||||
}
|
||||
|
||||
getCurrentPath () {}
|
||||
getCurrentPath() {}
|
||||
|
||||
normalize () {}
|
||||
normalize() {}
|
||||
|
||||
parse () {}
|
||||
parse() {}
|
||||
|
||||
toURL (path, params, currentRoute) {
|
||||
toURL(path, params, currentRoute) {
|
||||
const local = currentRoute && path[0] === '#'
|
||||
const route = this.parse(replaceSlug(path))
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import { History } from './base'
|
||||
import { noop } from '../../util/core'
|
||||
import { on } from '../../util/dom'
|
||||
import { parseQuery, cleanPath, replaceSlug } from '../util'
|
||||
import {History} from './base'
|
||||
import {noop} from '../../util/core'
|
||||
import {on} from '../../util/dom'
|
||||
import {parseQuery, cleanPath, replaceSlug} from '../util'
|
||||
|
||||
function replaceHash (path) {
|
||||
function replaceHash(path) {
|
||||
const i = location.href.indexOf('#')
|
||||
location.replace(location.href.slice(0, i >= 0 ? i : 0) + '#' + path)
|
||||
}
|
||||
|
||||
export class HashHistory extends History {
|
||||
constructor (config) {
|
||||
constructor(config) {
|
||||
super(config)
|
||||
this.mode = 'hash'
|
||||
}
|
||||
|
||||
getBasePath () {
|
||||
getBasePath() {
|
||||
const path = window.location.pathname || ''
|
||||
const base = this.config.basePath
|
||||
|
||||
return /^(\/|https?:)/g.test(base) ? base : cleanPath(path + '/' + base)
|
||||
}
|
||||
|
||||
getCurrentPath () {
|
||||
getCurrentPath() {
|
||||
// We can't use location.hash here because it's not
|
||||
// consistent across browsers - Firefox will pre-decode it!
|
||||
const href = location.href
|
||||
@@ -29,16 +29,18 @@ export class HashHistory extends History {
|
||||
return index === -1 ? '' : href.slice(index + 1)
|
||||
}
|
||||
|
||||
onchange (cb = noop) {
|
||||
onchange(cb = noop) {
|
||||
on('hashchange', cb)
|
||||
}
|
||||
|
||||
normalize () {
|
||||
normalize() {
|
||||
let path = this.getCurrentPath()
|
||||
|
||||
path = replaceSlug(path)
|
||||
|
||||
if (path.charAt(0) === '/') return replaceHash(path)
|
||||
if (path.charAt(0) === '/') {
|
||||
return replaceHash(path)
|
||||
}
|
||||
replaceHash('/' + path)
|
||||
}
|
||||
|
||||
@@ -47,7 +49,7 @@ export class HashHistory extends History {
|
||||
* @param {string} [path=location.herf]
|
||||
* @return {object} { path, query }
|
||||
*/
|
||||
parse (path = location.href) {
|
||||
parse(path = location.href) {
|
||||
let query = ''
|
||||
|
||||
const hashIndex = path.indexOf('#')
|
||||
@@ -68,7 +70,7 @@ export class HashHistory extends History {
|
||||
}
|
||||
}
|
||||
|
||||
toURL (path, params, currentRoute) {
|
||||
toURL(path, params, currentRoute) {
|
||||
return '#' + super.toURL(path, params, currentRoute)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { History } from './base'
|
||||
import { noop } from '../../util/core'
|
||||
import { on } from '../../util/dom'
|
||||
import { parseQuery, getPath } from '../util'
|
||||
import {History} from './base'
|
||||
import {noop} from '../../util/core'
|
||||
import {on} from '../../util/dom'
|
||||
import {parseQuery, getPath} from '../util'
|
||||
|
||||
export class HTML5History extends History {
|
||||
constructor (config) {
|
||||
constructor(config) {
|
||||
super(config)
|
||||
this.mode = 'history'
|
||||
}
|
||||
|
||||
getCurrentPath () {
|
||||
getCurrentPath() {
|
||||
const base = this.getBasePath()
|
||||
let path = window.location.pathname
|
||||
|
||||
@@ -20,14 +20,14 @@ export class HTML5History extends History {
|
||||
return (path || '/') + window.location.search + window.location.hash
|
||||
}
|
||||
|
||||
onchange (cb = noop) {
|
||||
onchange(cb = noop) {
|
||||
on('click', e => {
|
||||
const el = e.target.tagName === 'A' ? e.target : e.target.parentNode
|
||||
|
||||
if (el.tagName === 'A' && !/_blank/.test(el.target)) {
|
||||
e.preventDefault()
|
||||
const url = el.href
|
||||
window.history.pushState({ key: url }, '', url)
|
||||
window.history.pushState({key: url}, '', url)
|
||||
cb()
|
||||
}
|
||||
})
|
||||
@@ -40,7 +40,7 @@ export class HTML5History extends History {
|
||||
* @param {string} [path=location.href]
|
||||
* @return {object} { path, query }
|
||||
*/
|
||||
parse (path = location.href) {
|
||||
parse(path = location.href) {
|
||||
let query = ''
|
||||
|
||||
const queryIndex = path.indexOf('?')
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { HashHistory } from './history/hash'
|
||||
import { HTML5History } from './history/html5'
|
||||
import { supportsPushState } from '../util/env'
|
||||
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) {
|
||||
export function routerMixin(proto) {
|
||||
proto.route = {}
|
||||
}
|
||||
|
||||
let lastRoute = {}
|
||||
|
||||
function updateRender (vm) {
|
||||
function updateRender(vm) {
|
||||
vm.router.normalize()
|
||||
vm.route = vm.router.parse()
|
||||
dom.body.setAttribute('data-page', vm.route.file)
|
||||
}
|
||||
|
||||
export function initRouter (vm) {
|
||||
export function initRouter(vm) {
|
||||
const config = vm.config
|
||||
const mode = config.routerMode || 'hash'
|
||||
let router
|
||||
|
||||
+16
-14
@@ -1,9 +1,9 @@
|
||||
import { cached } from '../util/core'
|
||||
import {cached} from '../util/core'
|
||||
|
||||
const decode = decodeURIComponent
|
||||
const encode = encodeURIComponent
|
||||
|
||||
export function parseQuery (query) {
|
||||
export function parseQuery(query) {
|
||||
const res = {}
|
||||
|
||||
query = query.trim().replace(/^(\?|#|&)/, '')
|
||||
@@ -22,39 +22,41 @@ export function parseQuery (query) {
|
||||
return res
|
||||
}
|
||||
|
||||
export function stringifyQuery (obj, ignores = []) {
|
||||
export function stringifyQuery(obj, ignores = []) {
|
||||
const qs = []
|
||||
|
||||
for (const key in obj) {
|
||||
if (ignores.indexOf(key) > -1) continue
|
||||
if (ignores.indexOf(key) > -1) {
|
||||
continue
|
||||
}
|
||||
qs.push(
|
||||
obj[key]
|
||||
? `${encode(key)}=${encode(obj[key])}`.toLowerCase()
|
||||
: encode(key)
|
||||
obj[key] ?
|
||||
`${encode(key)}=${encode(obj[key])}`.toLowerCase() :
|
||||
encode(key)
|
||||
)
|
||||
}
|
||||
|
||||
return qs.length ? `?${qs.join('&')}` : ''
|
||||
}
|
||||
|
||||
export function getPath (...args) {
|
||||
return cleanPath(args.join('/'))
|
||||
}
|
||||
|
||||
export const isAbsolutePath = cached(path => {
|
||||
return /(:|(\/{2}))/g.test(path)
|
||||
})
|
||||
|
||||
export const getParentPath = cached(path => {
|
||||
return /\/$/g.test(path)
|
||||
? path
|
||||
: (path = path.match(/(\S*\/)[^\/]+$/)) ? path[1] : ''
|
||||
return /\/$/g.test(path) ?
|
||||
path :
|
||||
(path = path.match(/(\S*\/)[^/]+$/)) ? path[1] : ''
|
||||
})
|
||||
|
||||
export const cleanPath = cached(path => {
|
||||
return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
|
||||
})
|
||||
|
||||
export function getPath(...args) {
|
||||
return cleanPath(args.join('/'))
|
||||
}
|
||||
|
||||
export const replaceSlug = cached(path => {
|
||||
return path.replace('#', '?id=')
|
||||
})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* Create a cached version of a pure function.
|
||||
*/
|
||||
export function cached (fn) {
|
||||
export function cached(fn) {
|
||||
const cache = Object.create(null)
|
||||
return function cachedFn (str) {
|
||||
return function (str) {
|
||||
const key = isPrimitive(str) ? str : JSON.stringify(str)
|
||||
const hit = cache[key]
|
||||
return hit || (cache[key] = fn(str))
|
||||
@@ -17,14 +17,14 @@ export const hyphenate = cached(str => {
|
||||
return str.replace(/([A-Z])/g, m => '-' + m.toLowerCase())
|
||||
})
|
||||
|
||||
export const hasOwn = Object.prototype.hasOwnProperty
|
||||
|
||||
/**
|
||||
* Simple Object.assign polyfill
|
||||
*/
|
||||
export const merge =
|
||||
Object.assign ||
|
||||
function (to) {
|
||||
const hasOwn = Object.prototype.hasOwnProperty
|
||||
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
const from = Object(arguments[i])
|
||||
|
||||
@@ -41,18 +41,18 @@ export const merge =
|
||||
/**
|
||||
* Check if value is primitive
|
||||
*/
|
||||
export function isPrimitive (value) {
|
||||
export function isPrimitive(value) {
|
||||
return typeof value === 'string' || typeof value === 'number'
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform no operation.
|
||||
*/
|
||||
export function noop () {}
|
||||
export function noop() {}
|
||||
|
||||
/**
|
||||
* Check if value is function
|
||||
*/
|
||||
export function isFn (obj) {
|
||||
export function isFn(obj) {
|
||||
return typeof obj === 'function'
|
||||
}
|
||||
|
||||
+21
-19
@@ -1,5 +1,5 @@
|
||||
import { isFn } from '../util/core'
|
||||
import { inBrowser } from './env'
|
||||
import {isFn} from '../util/core'
|
||||
import {inBrowser} from './env'
|
||||
|
||||
const cacheNode = {}
|
||||
|
||||
@@ -9,7 +9,7 @@ const cacheNode = {}
|
||||
* @param {Boolean} noCache
|
||||
* @return {Element}
|
||||
*/
|
||||
export function getNode (el, noCache = false) {
|
||||
export function getNode(el, noCache = false) {
|
||||
if (typeof el === 'string') {
|
||||
if (typeof window.Vue !== 'undefined') {
|
||||
return find(el)
|
||||
@@ -32,7 +32,7 @@ export const head = inBrowser && $.head
|
||||
* find('nav') => document.querySelector('nav')
|
||||
* find(nav, 'a') => nav.querySelector('a')
|
||||
*/
|
||||
export function find (el, node) {
|
||||
export function find(el, node) {
|
||||
return node ? el.querySelector(node) : $.querySelector(el)
|
||||
}
|
||||
|
||||
@@ -42,36 +42,38 @@ export function find (el, node) {
|
||||
* findAll('a') => [].slice.call(document.querySelectorAll('a'))
|
||||
* findAll(nav, 'a') => [].slice.call(nav.querySelectorAll('a'))
|
||||
*/
|
||||
export function findAll (el, node) {
|
||||
export function findAll(el, node) {
|
||||
return [].slice.call(
|
||||
node ? el.querySelectorAll(node) : $.querySelectorAll(el)
|
||||
)
|
||||
}
|
||||
|
||||
export function create (node, tpl) {
|
||||
export function create(node, tpl) {
|
||||
node = $.createElement(node)
|
||||
if (tpl) node.innerHTML = tpl
|
||||
if (tpl) {
|
||||
node.innerHTML = tpl
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
export function appendTo (target, el) {
|
||||
export function appendTo(target, el) {
|
||||
return target.appendChild(el)
|
||||
}
|
||||
|
||||
export function before (target, el) {
|
||||
export function before(target, el) {
|
||||
return target.insertBefore(el, target.children[0])
|
||||
}
|
||||
|
||||
export function on (el, type, handler) {
|
||||
isFn(type)
|
||||
? window.addEventListener(el, type)
|
||||
: el.addEventListener(type, handler)
|
||||
export function on(el, type, handler) {
|
||||
isFn(type) ?
|
||||
window.addEventListener(el, type) :
|
||||
el.addEventListener(type, handler)
|
||||
}
|
||||
|
||||
export function off (el, type, handler) {
|
||||
isFn(type)
|
||||
? window.removeEventListener(el, type)
|
||||
: el.removeEventListener(type, handler)
|
||||
export function off(el, type, handler) {
|
||||
isFn(type) ?
|
||||
window.removeEventListener(el, type) :
|
||||
el.removeEventListener(type, handler)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,10 +83,10 @@ export function off (el, type, handler) {
|
||||
* toggleClass(el, 'active') => el.classList.toggle('active')
|
||||
* toggleClass(el, 'add', 'active') => el.classList.add('active')
|
||||
*/
|
||||
export function toggleClass (el, type, val) {
|
||||
export function toggleClass(el, type, val) {
|
||||
el && el.classList[val ? type : 'toggle'](val || type)
|
||||
}
|
||||
|
||||
export function style (content) {
|
||||
export function style(content) {
|
||||
appendTo(head, create('style', content))
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export const supportsPushState =
|
||||
window.history &&
|
||||
window.history.pushState &&
|
||||
window.history.replaceState &&
|
||||
// pushState isn’t reliable on iOS until 5.
|
||||
// PushState isn’t reliable on iOS until 5.
|
||||
!navigator.userAgent.match(
|
||||
/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as dom from '../dom'
|
||||
import { get } from '../../fetch/ajax'
|
||||
import {get} from '../../fetch/ajax'
|
||||
|
||||
function replaceVar (block, color) {
|
||||
function replaceVar(block, color) {
|
||||
block.innerHTML = block.innerHTML.replace(
|
||||
/var\(\s*--theme-color.*?\)/g,
|
||||
color
|
||||
@@ -10,16 +10,20 @@ function replaceVar (block, color) {
|
||||
|
||||
export default function (color) {
|
||||
// Variable support
|
||||
if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) { return }
|
||||
if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) {
|
||||
return
|
||||
}
|
||||
|
||||
const styleBlocks = dom.findAll('style:not(.inserted),link')
|
||||
;[].forEach.call(styleBlocks, block => {
|
||||
const styleBlocks = dom.findAll('style:not(.inserted),link');
|
||||
[].forEach.call(styleBlocks, block => {
|
||||
if (block.nodeName === 'STYLE') {
|
||||
replaceVar(block, color)
|
||||
} else if (block.nodeName === 'LINK') {
|
||||
const href = block.getAttribute('href')
|
||||
|
||||
if (!/\.css$/.test(href)) return
|
||||
if (!/\.css$/.test(href)) {
|
||||
return
|
||||
}
|
||||
|
||||
get(href).then(res => {
|
||||
const style = dom.create('style', res)
|
||||
|
||||
@@ -3,7 +3,7 @@ if (fixedPath !== location.href) {
|
||||
location.href = fixedPath
|
||||
}
|
||||
|
||||
function install (hook, vm) {
|
||||
function install(hook, vm) {
|
||||
const dom = Docsify.dom
|
||||
const disqus = vm.config.disqus
|
||||
if (!disqus) {
|
||||
@@ -15,7 +15,7 @@ function install (hook, vm) {
|
||||
|
||||
script.async = true
|
||||
script.src = `https://${disqus}.disqus.com/embed.js`
|
||||
script.setAttribute('data-timestamp', +new Date())
|
||||
script.setAttribute('data-timestamp', Number(new Date()))
|
||||
dom.appendTo(dom.body, script)
|
||||
})
|
||||
|
||||
|
||||
@@ -887,12 +887,12 @@ const AllGithubEmoji = [
|
||||
'zzz'
|
||||
]
|
||||
|
||||
// emoji from All-Github-Emoji-Icons
|
||||
// Emoji from All-Github-Emoji-Icons
|
||||
// https://github.com/scotch-io/All-Github-Emoji-Icons
|
||||
window.emojify = function (match, $1) {
|
||||
return AllGithubEmoji.indexOf($1) === -1
|
||||
? match
|
||||
: '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' +
|
||||
return AllGithubEmoji.indexOf($1) === -1 ?
|
||||
match :
|
||||
'<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' +
|
||||
$1 +
|
||||
'.png" alt="' +
|
||||
$1 +
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function handleExternalScript () {
|
||||
function handleExternalScript() {
|
||||
const container = Docsify.dom.getNode('#main')
|
||||
const scripts = Docsify.dom.findAll(container, 'script')
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import parser from './parser'
|
||||
|
||||
const install = function (hook, vm) {
|
||||
hook.beforeEach(content => {
|
||||
const { attributes, body } = parser(content)
|
||||
const {attributes, body} = parser(content)
|
||||
|
||||
Docsify.util.merge(vm.config, attributes.config)
|
||||
vm.frontmatter = attributes
|
||||
|
||||
return body
|
||||
})
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user