diff --git a/.eslintignore b/.eslintignore
index 07dc46e..a3b8548 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,5 @@
-.git/
+.git
packages/docsify-server-renderer/build.js
-node_modules
\ No newline at end of file
+node_modules
+build
+server.js
\ No newline at end of file
diff --git a/.eslintrc b/.eslintrc
index 3a6f901..a8f7cd0 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -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
}
}
diff --git a/README.md b/README.md
index 52ca73c..262869e 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/app.js b/app.js
deleted file mode 100644
index 63f80f7..0000000
--- a/app.js
+++ /dev/null
@@ -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: `
-
-
-
-
- docsify
-
-
-
-
-
-
-
-
-`,
- 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`)
diff --git a/build/build-css.js b/build/build-css.js
deleted file mode 100644
index b1b239e..0000000
--- a/build/build-css.js
+++ /dev/null
@@ -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)
- })
-})
diff --git a/build/build.js b/build/build.js
index 6185f59..c7e8c1b 100644
--- a/build/build.js
+++ b/build/build.js
@@ -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()
}
diff --git a/build/build-cover.js b/build/cover.js
similarity index 100%
rename from build/build-cover.js
rename to build/cover.js
diff --git a/build/build-ssr.js b/build/ssr.js
similarity index 100%
rename from build/build-ssr.js
rename to build/ssr.js
diff --git a/docs/configuration.md b/docs/configuration.md
index e4078ed..3194c10 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -420,8 +420,8 @@ window.$docsify = {
List of languages that will fallback to the default language when a page is request and didn't exists for the given local.
-Example:
-
+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.
diff --git a/dev.html b/index.html
similarity index 95%
rename from dev.html
rename to index.html
index f61b9f4..329fae4 100644
--- a/dev.html
+++ b/index.html
@@ -1,5 +1,6 @@
+
docsify
@@ -14,6 +15,7 @@
}
+
-
+
+