diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 4c0bc8468..4e6fad009 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -62,4 +62,3 @@ If yes, please describe the impact and migration path for existing applications:
- [ ] Firefox
- [ ] Safari
- [ ] Edge
-- [ ] IE
diff --git a/README.md b/README.md
index b6e6ab7f5..8c665fc5a 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,6 @@
- Smart full-text search plugin
- Multiple themes
- Useful plugin API
-- Compatible with IE11
- Support embedded files
## Quick start
diff --git a/build/build.js b/build/build.js
index ca50d4e1f..6a3726ed5 100644
--- a/build/build.js
+++ b/build/build.js
@@ -26,14 +26,15 @@ async function build(opts) {
await rollup
.rollup({
input: opts.input,
- plugins: (opts.plugins || []).concat([
+ plugins: [
+ ...(opts.plugins || []),
commonjs(),
nodeResolve(),
replace({
__VERSION__: version,
})
- ]),
- onwarn: function (message) {
+ ],
+ onwarn(message) {
if (message.code === 'UNRESOLVED_IMPORT') {
throw new Error(
`Could not resolve module ` +
@@ -44,8 +45,8 @@ async function build(opts) {
}
}
})
- .then(function (bundle) {
- var dest = 'lib/' + (opts.output || opts.input)
+ .then(bundle => {
+ const dest = 'lib/' + (opts.output || opts.input)
console.log(dest)
return bundle.write({
@@ -77,7 +78,7 @@ async function buildCore() {
}
async function buildAllPlugin() {
- var plugins = [
+ const plugins = [
{name: 'search', input: 'search/index.js'},
{name: 'ga', input: 'ga.js'},
{name: 'gtag', input: 'gtag.js'},
diff --git a/build/cover.js b/build/cover.js
index 996e52569..9d64aebed 100644
--- a/build/cover.js
+++ b/build/cover.js
@@ -1,17 +1,17 @@
import fs from 'fs';
import { relative } from './util.js';
-var read = fs.readFileSync;
-var write = fs.writeFileSync;
+const read = fs.readFileSync;
+const write = fs.writeFileSync;
const pkgPath = relative(import.meta, '..', 'package.json');
const pkg = JSON.parse(read(pkgPath).toString());
-var version = process.env.VERSION || pkg.version;
+const version = process.env.VERSION || pkg.version;
-var file = relative(import.meta, '..', 'docs', '_coverpage.md');
-var cover = read(file, 'utf8').toString();
+const file = relative(import.meta, '..', 'docs', '_coverpage.md');
+let cover = read(file, 'utf8').toString();
console.log('Replace version number in cover page...');
cover = cover.replace(
/(\S+)?<\/small>/g,
- '' + version + ''
+ /* html */ `${version}`
);
write(file, cover);
diff --git a/build/css.js b/build/css.js
index baf981628..1047c5868 100644
--- a/build/css.js
+++ b/build/css.js
@@ -11,17 +11,16 @@ fs.readdir(relative('../src/themes'), (err, files) => {
}
files.map(async (file) => {
if (/\.styl/g.test(file)) {
- var stylusCMD;
const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(path.sep)
- var cmdargs = [
+ let cmdargs = [
stylusBin,
`src/themes/${file}`,
'-u',
'autoprefixer-stylus'
]
- cmdargs = cmdargs.concat(args)
+ cmdargs = [...cmdargs, ...args]
- stylusCMD = spawn('node', cmdargs, { shell: true })
+ const stylusCMD = spawn('node', cmdargs, { shell: true })
stylusCMD.stdout.on('data', (data) => {
console.log(`[Stylus Build ] stdout: ${data}`);
diff --git a/build/emoji.js b/build/emoji.js
index f9d5d0aa2..0dc41dc3b 100644
--- a/build/emoji.js
+++ b/build/emoji.js
@@ -93,17 +93,15 @@ function writeEmojiJS(emojiData) {
}
}
-(async () => {
- console.info('Build emoji');
-
- try {
- const emojiData = await getEmojiData();
-
- if (emojiData) {
- writeEmojiPage(emojiData);
- writeEmojiJS(emojiData);
- }
- } catch (err) {
- console.warn(`- Error: ${err.message}`);
+console.info('Build emoji');
+
+try {
+ const emojiData = await getEmojiData();
+
+ if (emojiData) {
+ writeEmojiPage(emojiData);
+ writeEmojiJS(emojiData);
}
-})();
+} catch (err) {
+ console.warn(`- Error: ${err.message}`);
+}
diff --git a/docs/README.md b/docs/README.md
index f9d03d874..f85aa72ab 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -16,7 +16,6 @@ See the [Quick start](quickstart.md) guide for more details.
- Multiple themes
- Useful plugin API
- Emoji support
-- Compatible with IE11
## Examples
diff --git a/docs/_media/example.js b/docs/_media/example.js
index 8cad2d730..33bdf862c 100644
--- a/docs/_media/example.js
+++ b/docs/_media/example.js
@@ -1,16 +1,16 @@
-import fetch from 'fetch'
+import fetch from 'fetch';
-const URL = 'https://example.com'
-const PORT = 8080
+const URL = 'https://example.com';
+const PORT = 8080;
/// [demo]
const result = fetch(`${URL}:${PORT}`)
- .then(function (response) {
- return response.json()
- })
- .then(function (myJson) {
- console.log(JSON.stringify(myJson))
+ .then(response => {
+ return response.json();
})
+ .then(myJson => {
+ console.log(JSON.stringify(myJson));
+ });
/// [demo]
-result.then(console.log).catch(console.error)
+result.then(console.log).catch(console.error);
diff --git a/docs/configuration.md b/docs/configuration.md
index 4b238da76..6461dcea8 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -249,7 +249,7 @@ See https://github.com/lukeed/tinydate#patterns
window.$docsify = {
formatUpdated: '{MM}/{DD} {HH}:{mm}',
- formatUpdated: function (time) {
+ formatUpdated(time) {
// ...
return time;
@@ -346,14 +346,14 @@ window.$docsify = {
markdown: {
smartypants: true,
renderer: {
- link: function () {
+ link() {
// ...
},
},
},
// function
- markdown: function (marked, renderer) {
+ markdown(marked, renderer) {
// ...
return marked;
},
@@ -747,18 +747,17 @@ window.$docsify = {
'/foo': '# Custom Markdown',
// RegEx match w/ synchronous function
- '/bar/(.*)': function (route, matched) {
+ '/bar/(.*)'(route, matched) {
return '# Custom Markdown';
},
// RegEx match w/ asynchronous function
- '/baz/(.*)': function (route, matched, next) {
- // Requires `fetch` polyfill for legacy browsers (https://github.github.io/fetch/)
+ '/baz/(.*)'(route, matched, next) {
fetch('/api/users?id=12345')
- .then(function (response) {
+ .then(response => {
next('# Custom Markdown');
})
- .catch(function (err) {
+ .catch(err => {
// Handle error...
});
},
@@ -772,7 +771,7 @@ Other than strings, route functions can return a falsy value (`null` \ `undefine
window.$docsify = {
routes: {
// accepts everything other than dogs (synchronous)
- '/pets/(.+)': function(route, matched) {
+ '/pets/(.+)'(route, matched) {
if (matched[0] === 'dogs') {
return null;
} else {
@@ -781,7 +780,7 @@ window.$docsify = {
}
// accepts everything other than cats (asynchronous)
- '/pets/(.*)': function(route, matched, next) {
+ '/pets/(.*)'(route, matched, next) {
if (matched[0] === 'cats') {
next();
} else {
@@ -799,12 +798,12 @@ Finally, if you have a specific path that has a real markdown file (and therefor
window.$docsify = {
routes: {
// if you look up /pets/cats, docsify will skip all routes and look for "pets/cats.md"
- '/pets/cats': function(route, matched) {
+ '/pets/cats'(route, matched) {
return false;
}
// but any other pet should generate dynamic content right here
- '/pets/(.+)': function(route, matched) {
+ '/pets/(.+)'(route, matched) {
const pet = matched[0];
return `your pet is ${pet} (but not a cat)`;
}
@@ -835,11 +834,19 @@ If you have a link to the homepage in the sidebar and want it to be shown as act
For more details, see [#1131](https://github.com/docsifyjs/docsify/issues/1131).
-## themeColor
+## themeColor (_deprecated_)
+
+> **Warning** Deprecated. Use the CSS var `--theme-color` in your `
- 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 older browsers.
+Customize the theme color.
```js
window.$docsify = {
diff --git a/docs/index.html b/docs/index.html
index db0774355..2eaeb3acb 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -8,7 +8,6 @@
name="google-site-verification"
content="6t0LoIeFksrjF4c9sqUEsVXiQNxLp2hgoqo0KryT-sE"
/>
-
-var num = 0;
+let num = 0;
mermaid.initialize({ startOnLoad: false });
window.$docsify = {
markdown: {
renderer: {
- code: function(code, lang) {
+ code(code, lang) {
if (lang === "mermaid") {
- return (
- '
afterEach
'; }); }, @@ -136,8 +136,8 @@ test.describe('Plugins', () => { config: { plugins: [ function (hook, vm) { - hook.afterEach(function (html, next) { - setTimeout(function () { + hook.afterEach((html, next) => { + setTimeout(() => { next('afterEach
'); }, 100); }); diff --git a/test/e2e/virtual-routes.test.js b/test/e2e/virtual-routes.test.js index ba31adcb0..b84ca30ca 100644 --- a/test/e2e/virtual-routes.test.js +++ b/test/e2e/virtual-routes.test.js @@ -101,9 +101,7 @@ test.describe('Virtual Routes - Generate Dynamic Content via Config', () => { page, }) => { const routes = { - '/pets/(.*)': function (route) { - return `# Route: /pets/dog`; - }, + '/pets/(.*)': route => `# Route: /pets/dog`, }; await docsifyInit({ @@ -122,7 +120,7 @@ test.describe('Virtual Routes - Generate Dynamic Content via Config', () => { page, }) => { const routes = { - '/pets/(.*)': function (_, matched) { + '/pets/(.*)'(_, matched) { return `# Pets Page (${matched[1]})`; }, }; diff --git a/test/e2e/vue.test.js b/test/e2e/vue.test.js index fde2dcd8c..0edbb43d5 100644 --- a/test/e2e/vue.test.js +++ b/test/e2e/vue.test.js @@ -24,16 +24,14 @@ test.describe('Vue.js Compatibility', () => { }, }, vueGlobalOptions: { - data: function () { - return { - counter: 0, - msg: 'vueglobaloptions', - }; - }, + data: () => ({ + counter: 0, + msg: 'vueglobaloptions', + }), }, vueMounts: { '#vuemounts': { - data: function () { + data() { return { counter: 0, msg: 'vuemounts', diff --git a/test/helpers/docsify-init.js b/test/helpers/docsify-init.js index a64585691..3441046ea 100644 --- a/test/helpers/docsify-init.js +++ b/test/helpers/docsify-init.js @@ -225,11 +225,29 @@ async function docsifyInit(options = {}) { await page.evaluate(config => { // Restore config functions from strings - const configObj = JSON.parse(config, (key, val) => - /^__FN__/.test(val) - ? new Function(`return ${val.split('__FN__')[1]}`)() - : val - ); + const configObj = JSON.parse(config, (key, val) => { + if (/^__FN__/.test(val)) { + let source = val.split('__FN__')[1]; + + // f.e. `foo() {}` or `'bar!?'() {}` without the `function ` prefix + const isConcise = + !source.includes('function') && !source.includes('=>'); + + if (isConcise) { + source = `{ ${source} }`; + } else { + source = `{ _: ${source} }`; + } + + return new Function(/* js */ ` + const o = ${source} + const keys = Object.keys(o) + return o[keys[0]] + `)(); + } else { + return val; + } + }); window.$docsify = configObj; }, configString); diff --git a/test/integration/__snapshots__/docs.test.js.snap b/test/integration/__snapshots__/docs.test.js.snap index ffe44b777..2e620b9dd 100644 --- a/test/integration/__snapshots__/docs.test.js.snap +++ b/test/integration/__snapshots__/docs.test.js.snap @@ -1,12 +1,26 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Docs Site coverpage renders and is unchanged 1`] = ` -"+"+ + " +Getting Started
docsify 4.13.0
A magical documentation site generator.
- Simple and lightweight
- No statically built html files
- Multiple themes
:100:
:100:
diff --git a/test/integration/render.test.js b/test/integration/render.test.js
index d2b12527e..8b65f11ca 100644
--- a/test/integration/render.test.js
+++ b/test/integration/render.test.js
@@ -104,7 +104,7 @@ describe('render', function () {
const output = window.marked('');
expect(output).toMatchInlineSnapshot(
- `"