diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index bb31bd41f..2d5b3e545 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,6 +14,7 @@ - [ ] Refactor - [ ] Docs - [ ] Build-related changes +- [ ] Repo settings - [ ] Other, please describe: If changing the UI of default theme, please provide the **before/after** screenshot: @@ -44,11 +45,3 @@ If adding a **new feature**, the PR's description includes: - [ ] Related tests have been updated To avoid wasting your time, it's best to open a **feature request issue** first and wait for approval before working on it. - - -**Other information:** - ---- - -* [ ] DO NOT include files inside `lib` directory. - diff --git a/.gitignore b/.gitignore index e9803a96f..dc015fd2a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,10 @@ .DS_Store .idea node_modules -themes/ -lib/ -cypress/integration/examples -cypress/fixtures/docs +/themes/ +/lib/ +/cypress/integration/examples +/cypress/fixtures/docs # exceptions -!.gitkeep \ No newline at end of file +!.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md index 784dec697..facd1fe95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,32 @@ +## [4.11.5](https://github.com/docsifyjs/docsify/compare/v4.11.4...v4.11.5) (2020-08-21) + + +### Bug Fixes + +* Russian language link error ([#1270](https://github.com/docsifyjs/docsify/issues/1270)) ([2a52460](https://github.com/docsifyjs/docsify/commit/2a52460a59448abaf681046fbc5dca642285ae1f)) +* {docsify-updated} in the sample code is parsed into time ([#1321](https://github.com/docsifyjs/docsify/issues/1321)) ([2048610](https://github.com/docsifyjs/docsify/commit/2048610aacd4e3c6a592f4247834a726c7ca33fb)) +* Add error handling for missing dependencies (fixes [#1210](https://github.com/docsifyjs/docsify/issues/1210)) ([#1232](https://github.com/docsifyjs/docsify/issues/1232)) ([3673001](https://github.com/docsifyjs/docsify/commit/3673001a24cb24c57454f9bc7619de49d2c3a044)) +* after setting the background image, the button is obscured ([#1234](https://github.com/docsifyjs/docsify/issues/1234)) ([34d918f](https://github.com/docsifyjs/docsify/commit/34d918f9973bdb8e893248853e3ef7e803d4c253)) +* convert {docsify-ignore} and {docsify-ignore-all} to HTML comments ([#1318](https://github.com/docsifyjs/docsify/issues/1318)) ([90d283d](https://github.com/docsifyjs/docsify/commit/90d283d340502456a5d8495df596bb4a02ceb39b)) +* fallback page should use path not file location ([#1301](https://github.com/docsifyjs/docsify/issues/1301)) ([2bceabc](https://github.com/docsifyjs/docsify/commit/2bceabcb8e623570540493e2f1d956adf45c99e7)) +* Fix search error when exist translations documents ([#1300](https://github.com/docsifyjs/docsify/issues/1300)) ([b869019](https://github.com/docsifyjs/docsify/commit/b8690199006366e86084e9e018def7b9b8f46512)) +* gitignore was ignoring folders in src, so VS Code search results or file fuzzy finder were not working, etc ([d4c9247](https://github.com/docsifyjs/docsify/commit/d4c9247b87c0a2701683ed1a17383cfb451cf609)) +* packages/docsify-server-renderer/package.json & packages/docsify-server-renderer/package-lock.json to reduce vulnerabilities ([#1250](https://github.com/docsifyjs/docsify/issues/1250)) ([d439bac](https://github.com/docsifyjs/docsify/commit/d439bac93f479d0480799880538fc3104e54c907)) +* search can not search the table header ([#1256](https://github.com/docsifyjs/docsify/issues/1256)) ([3f03e78](https://github.com/docsifyjs/docsify/commit/3f03e78418993d8e9a4f5062e10dc79c3753389e)) +* Search plugin: matched text is replaced with search text ([#1298](https://github.com/docsifyjs/docsify/issues/1298)) ([78775b6](https://github.com/docsifyjs/docsify/commit/78775b6ee73102cc5ac71c0ee2b392c5f4f6f4f8)) +* the uncaught typeerror when el is null ([#1308](https://github.com/docsifyjs/docsify/issues/1308)) ([952f4c9](https://github.com/docsifyjs/docsify/commit/952f4c921b7a6a558c500ca6b105582d39ad36a2)) +* Updated docs with instructions for installing specific version (fixes [#780](https://github.com/docsifyjs/docsify/issues/780)) ([#1225](https://github.com/docsifyjs/docsify/issues/1225)) ([b90c948](https://github.com/docsifyjs/docsify/commit/b90c948090e89fa778279c95060dbd7668285658)) +* upgrade medium-zoom from 1.0.5 to 1.0.6 ([3beaa66](https://github.com/docsifyjs/docsify/commit/3beaa6666b78518f1ffaa37f6942f3cb08fef896)) +* upgrade tinydate from 1.2.0 to 1.3.0 ([#1341](https://github.com/docsifyjs/docsify/issues/1341)) ([59d090f](https://github.com/docsifyjs/docsify/commit/59d090fe9096bc03e259c166634bb75bb2623f85)) + + +### Features + +* **search:** add pathNamespaces option ([d179dde](https://github.com/docsifyjs/docsify/commit/d179dde1c71acdcbe66cb762377b123926c55bf2)) +* Add title to sidebar links ([#1286](https://github.com/docsifyjs/docsify/issues/1286)) ([667496b](https://github.com/docsifyjs/docsify/commit/667496b85d99b168255f58e60a6bfe902cc6ee03)) + + + ## [4.11.4](https://github.com/docsifyjs/docsify/compare/v4.11.3...v4.11.4) (2020-06-18) diff --git a/README.md b/README.md index bdd2fa558..0d44dec32 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- docsify + docsify

diff --git a/build/build.js b/build/build.js index 563861373..0de786828 100644 --- a/build/build.js +++ b/build/build.js @@ -22,7 +22,10 @@ async function build(opts) { .rollup({ input: opts.input, plugins: (opts.plugins || []).concat([ - buble(), + buble({ + transforms: { + dangerousForOf: true + }}), commonjs(), nodeResolve(), replace({ @@ -33,8 +36,8 @@ async function build(opts) { onwarn: function (message) { if (message.code === 'UNRESOLVED_IMPORT') { throw new Error( - `Could not resolve module ` + - message.source + + `Could not resolve module ` + + message.source + `. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` + `Module ${message.source} is imported in ${message.importer}` ) diff --git a/cypress/fixtures/tpl/docs.index.html b/cypress/fixtures/tpl/docs.index.html index a4b4c831f..3ffe35230 100644 --- a/cypress/fixtures/tpl/docs.index.html +++ b/cypress/fixtures/tpl/docs.index.html @@ -28,7 +28,7 @@ alias: { '.*?/awesome': 'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md', - '.*?/changelog': + '/changelog': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG.md', '/.*/_navbar.md': '/_navbar.md', '/zh-cn/(.*)': @@ -40,6 +40,7 @@ '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1' }, + fallbackLanguages: ['es'], auto2top: true, coverpage: true, executeScript: true, diff --git a/cypress/integration/routing/fallback.spec.js b/cypress/integration/routing/fallback.spec.js new file mode 100644 index 000000000..2e9951102 --- /dev/null +++ b/cypress/integration/routing/fallback.spec.js @@ -0,0 +1,9 @@ +context('config.fallbackLanguages', () => { + it('fallbacks respecting aliases', () => { + cy.visit('http://localhost:3000/#/es/'); + + cy.get('.sidebar-nav').contains('Changelog').click(); + + cy.get('#main').should('contain', 'Bug Fixes'); + }) +}); diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 07c318651..51db8d2e9 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](_media/icon.svg) -# docsify 4.11.4 +# docsify 4.11.5 > A magical documentation site generator. diff --git a/docs/cdn.md b/docs/cdn.md index 82b2d2d90..05fff3c28 100644 --- a/docs/cdn.md +++ b/docs/cdn.md @@ -44,7 +44,7 @@ Alternatively, use [compressed files](#compressed-file). ## Other CDN -- http://www.bootcdn.cn/docsify +- https://www.bootcdn.cn/docsify/ - https://cdn.jsdelivr.net/npm/docsify/ - https://cdnjs.com/libraries/docsify - +- https://unpkg.com/browse/docsify/ diff --git a/docs/configuration.md b/docs/configuration.md index 371ed35f6..1b2d04878 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -12,7 +12,7 @@ You can configure Docsify by defining `window.$docsify` as an object: ``` -The config can also be defined as a function, in which case the first arg is the Docsify `vm` instance. The function should return a config object. This can be useful for referencing `vm` in places like the markdown configuration: +The config can also be defined as a function, in which case the first argument is the Docsify `vm` instance. The function should return a config object. This can be useful for referencing `vm` in places like the markdown configuration: ```html @@ -33,7 +37,8 @@ '/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1', '/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1', '/ru-ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1', - '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1' + '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1', + '/write-a-plugin': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/docs/write-a-plugin.md' }, auto2top: true, coverpage: true, @@ -62,8 +67,8 @@ '/': 'Search' } }, - formatUpdated: '{MM}/{DD} {HH}:{mm}', plugins: [ + DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg'), function (hook, vm) { hook.beforeEach(function (html) { if (/githubusercontent\.com/.test(vm.route.file)) { diff --git a/docs/more-pages.md b/docs/more-pages.md index 429eaf97a..0f9386848 100644 --- a/docs/more-pages.md +++ b/docs/more-pages.md @@ -114,24 +114,24 @@ A custom sidebar can also automatically generate a table of contents by setting ## Ignoring Subheaders -When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `{docsify-ignore}` to it. +When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `` to it. ```markdown # Getting Started -## Header {docsify-ignore} +## Header This header won't appear in the sidebar table of contents. ``` -To ignore all headers on a specific page, you can use `{docsify-ignore-all}` on the first header of the page. +To ignore all headers on a specific page, you can use `` on the first header of the page. ```markdown -# Getting Started {docsify-ignore-all} +# Getting Started ## Header This header won't appear in the sidebar table of contents. ``` -Both `{docsify-ignore}` and `{docsify-ignore-all}` will not be rendered on the page when used. +Both `` and `` will not be rendered on the page when used. diff --git a/docs/plugins.md b/docs/plugins.md index 51acefbb5..feca8b551 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -44,6 +44,17 @@ By default, the hyperlink on the current page is recognized and the content is s // To avoid search index collision // between multiple websites under the same domain namespace: 'website-1', + + // Use different indexes for path prefixes (namespaces). + // NOTE: Only works in 'auto' mode. + // + // When initialiazing an index, we look for the first path from the sidebar. + // If it matches the prefix from the list, we switch to the corresponding index. + pathNamespaces: ['/zh-cn', '/ru-ru', '/ru-ru/v1'], + + // You can provide a regexp to match prefixes. In this case, + // the matching substring will be used to identify the index + pathNamespaces: /^(\/(zh-cn|ru-ru))?(\/(v1|v2))?/ } } diff --git a/index.html b/index.html index 5d2319844..8247ce5f5 100644 --- a/index.html +++ b/index.html @@ -9,10 +9,16 @@ + + @@ -27,7 +33,8 @@ '/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1', '/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1', '/ru-ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1', - '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1' + '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1', + '/write-a-plugin': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/docs/write-a-plugin.md' }, auto2top: true, basePath: '/docs/', @@ -50,10 +57,11 @@ '/de-de/': 'Suche', '/zh-cn/': '搜索', '/': 'Search' - } + }, + pathNamespaces: ['/zh-cn', '/de-de', '/ru-ru', '/es'] }, - formatUpdated: '{MM}/{DD} {HH}:{mm}', plugins: [ + DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg'), function (hook, vm) { hook.beforeEach(function (html) { if (/githubusercontent\.com/.test(vm.route.file)) { @@ -68,7 +76,6 @@ url = 'https://github.com/docsifyjs/docsify/blob/master/docs/' + vm.route.file } var editHtml = '[:memo: Edit Document](' + url + ')\n' - return editHtml + html + '\n\n----\n\n' @@ -82,9 +89,10 @@ - - - + + + + diff --git a/package-lock.json b/package-lock.json index 7ac8f91c2..6cd171362 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "docsify", - "version": "4.11.4", + "version": "4.11.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -5903,7 +5903,7 @@ "dependencies": { "split": { "version": "0.3.3", - "resolved": "http://registry.npmjs.org/split/-/split-0.3.3.tgz", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", "dev": true, "requires": { @@ -9536,7 +9536,7 @@ }, "magic-string": { "version": "0.22.5", - "resolved": "http://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz", "integrity": "sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==", "dev": true, "requires": { @@ -9599,9 +9599,9 @@ } }, "marked": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz", - "integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/marked/-/marked-1.1.1.tgz", + "integrity": "sha512-mJzT8D2yPxoPh7h0UXkB+dBj4FykPJ2OIfxAWeIHrvoHDkFxukV/29QxoFQoPM6RLEwhIFdJpmKBlqVM3s2ZIw==" }, "mdn-data": { "version": "2.0.4", @@ -9610,9 +9610,9 @@ "dev": true }, "medium-zoom": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/medium-zoom/-/medium-zoom-1.0.5.tgz", - "integrity": "sha512-aLGa6WlTuFKWvH88bqTrY5ztJMN+D0hd8UX6BYc4YSoPayppzETjZUcdVcksgaoQEMg4cZSmXPg846fTp2rjRQ==" + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/medium-zoom/-/medium-zoom-1.0.6.tgz", + "integrity": "sha512-UdiUWfvz9fZMg1pzf4dcuqA0W079o0mpqbTnOz5ip4VGYX96QjmbM+OgOU/0uOzAytxC0Ny4z+VcYQnhdifimg==" }, "memorystream": { "version": "0.3.1", @@ -11829,9 +11829,9 @@ } }, "prismjs": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.19.0.tgz", - "integrity": "sha512-IVFtbW9mCWm9eOIaEkNyo2Vl4NnEifis2GQ7/MLRG5TQe6t+4Sj9J5QWI9i3v+SS43uZBlCAOn+zYTVYQcPXJw==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.21.0.tgz", + "integrity": "sha512-uGdSIu1nk3kej2iZsLyDoJ7e9bnPzIgY0naW/HdknGj61zScaprVEVGHrPoXqI+M9sP0NDnTK2jpkvmldpuqDw==", "requires": { "clipboard": "^2.0.0" } @@ -13950,9 +13950,9 @@ "optional": true }, "tinydate": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tinydate/-/tinydate-1.2.0.tgz", - "integrity": "sha512-3GwPk8VhDFnUZ2TrgkhXJs6hcMAIIw4x/xkz+ayK6dGoQmp2nUwKzBXK0WnMsqkh6vfUhpqQicQF3rbshfyJkg==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tinydate/-/tinydate-1.3.0.tgz", + "integrity": "sha512-7cR8rLy2QhYHpsBDBVYnnWXm8uRTr38RoZakFSW7Bs7PzfMPNZthuMLkwqZv7MTu8lhQ91cOFYS5a7iFj2oR3w==" }, "tmp": { "version": "0.0.33", @@ -14561,9 +14561,9 @@ } }, "websocket-extensions": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", - "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz", + "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==", "dev": true }, "whatwg-encoding": { diff --git a/package.json b/package.json index 699b6d37e..77dc42fdc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docsify", - "version": "4.11.4", + "version": "4.11.5", "description": "A magical documentation generator.", "author": { "name": "qingwei-li", @@ -17,7 +17,6 @@ "unpkg": "lib/docsify.min.js", "files": [ "lib", - "src", "themes" ], "scripts": { @@ -58,12 +57,12 @@ }, "dependencies": { "dompurify": "^2.0.8", - "marked": "^0.7.0", - "medium-zoom": "^1.0.5", + "marked": "^1.1.1", + "medium-zoom": "^1.0.6", "opencollective-postinstall": "^2.0.2", "prismjs": "^1.19.0", "strip-indent": "^3.0.0", - "tinydate": "^1.0.0", + "tinydate": "^1.3.0", "tweezer.js": "^1.4.0" }, "devDependencies": { diff --git a/packages/docsify-server-renderer/README.md b/packages/docsify-server-renderer/README.md index 76c5f80dc..9968b1e0b 100644 --- a/packages/docsify-server-renderer/README.md +++ b/packages/docsify-server-renderer/README.md @@ -14,7 +14,7 @@ var readFileSync = require('fs').readFileSync // init var renderer = new Renderer({ - template: readFileSync('./docs/index.template.html', 'utf-8')., + template: readFileSync('./docs/index.template.html', 'utf-8'), config: { name: 'docsify', repo: 'docsifyjs/docsify' @@ -35,12 +35,12 @@ renderer.renderToString(url) docsify - + - + ``` diff --git a/packages/docsify-server-renderer/package-lock.json b/packages/docsify-server-renderer/package-lock.json index 6f9b43f9d..12811bd6b 100644 --- a/packages/docsify-server-renderer/package-lock.json +++ b/packages/docsify-server-renderer/package-lock.json @@ -1,6 +1,6 @@ { "name": "docsify-server-renderer", - "version": "4.11.4", + "version": "4.11.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -30,10 +30,11 @@ "optional": true }, "docsify": { - "version": "4.11.2", - "resolved": "https://registry.npmjs.org/docsify/-/docsify-4.11.2.tgz", - "integrity": "sha512-vQVg+ERdYgrlgLcwTX9FdjUn3xb7PSwaiYopIAmCLraHJCr1e0r8Uzi2vm6XEwTrSrdd6C5j3Eg+QctsOGA4Gg==", + "version": "4.11.4", + "resolved": "https://registry.npmjs.org/docsify/-/docsify-4.11.4.tgz", + "integrity": "sha512-Qwt98y6ddM2Wb46gRH/zQpEAvw70AlIpzVlB9Wi2u2T2REg9O+bXMpJ27F5TaRTn2bD6SF1VyZYNUfimpihZwQ==", "requires": { + "dompurify": "^2.0.8", "marked": "^0.7.0", "medium-zoom": "^1.0.5", "opencollective-postinstall": "^2.0.2", @@ -68,9 +69,9 @@ "integrity": "sha512-aLGa6WlTuFKWvH88bqTrY5ztJMN+D0hd8UX6BYc4YSoPayppzETjZUcdVcksgaoQEMg4cZSmXPg846fTp2rjRQ==" }, "min-indent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.0.tgz", - "integrity": "sha1-z8RcN+nsDY8KDsPdTvf3w6vjklY=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==" }, "ms": { "version": "2.1.2", @@ -83,14 +84,14 @@ "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "opencollective-postinstall": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz", - "integrity": "sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw==" + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz", + "integrity": "sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==" }, "prismjs": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.19.0.tgz", - "integrity": "sha512-IVFtbW9mCWm9eOIaEkNyo2Vl4NnEifis2GQ7/MLRG5TQe6t+4Sj9J5QWI9i3v+SS43uZBlCAOn+zYTVYQcPXJw==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.21.0.tgz", + "integrity": "sha512-uGdSIu1nk3kej2iZsLyDoJ7e9bnPzIgY0naW/HdknGj61zScaprVEVGHrPoXqI+M9sP0NDnTK2jpkvmldpuqDw==", "requires": { "clipboard": "^2.0.0" } diff --git a/packages/docsify-server-renderer/package.json b/packages/docsify-server-renderer/package.json index d11ee6817..9075a03f4 100644 --- a/packages/docsify-server-renderer/package.json +++ b/packages/docsify-server-renderer/package.json @@ -1,6 +1,6 @@ { "name": "docsify-server-renderer", - "version": "4.11.4", + "version": "4.11.5", "description": "docsify server renderer", "author": { "name": "qingwei-li", @@ -16,7 +16,7 @@ }, "dependencies": { "debug": "^4.1.1", - "docsify": "^4.11.2", + "docsify": "^4.11.4", "dompurify": "^2.0.8", "node-fetch": "^2.6.0", "resolve-pathname": "^3.0.0" diff --git a/src/core/event/scroll.js b/src/core/event/scroll.js index 946589996..96cdade5c 100644 --- a/src/core/event/scroll.js +++ b/src/core/event/scroll.js @@ -79,9 +79,12 @@ function highlight(path) { const isInView = active.offsetTop >= wrap.scrollTop && cur <= wrap.scrollTop + height; const notThan = cur - curOffset < height; - const top = isInView ? wrap.scrollTop : notThan ? curOffset : cur - height; - sidebar.scrollTop = top; + sidebar.scrollTop = isInView + ? wrap.scrollTop + : notThan + ? curOffset + : cur - height; } } diff --git a/src/core/event/sidebar.js b/src/core/event/sidebar.js index b15cb2afe..7ca72d94c 100644 --- a/src/core/event/sidebar.js +++ b/src/core/event/sidebar.js @@ -86,6 +86,8 @@ export function getAndActive(router, el, isParent, autoTitle) { const href = a.getAttribute('href'); const node = isParent ? a.parentNode : a; + a.title = a.innerText; + if (hash.indexOf(href) === 0 && !target) { target = a; dom.toggleClass(node, 'add', 'active'); diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 9d2769b84..6bf592c96 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -123,7 +123,7 @@ export function fetchMixin(proto) { this._loadSideAndNav(path, qs, loadSidebar, cb) ), _ => { - this._fetchFallbackPage(file, qs, cb) || this._fetch404(file, qs, cb); + this._fetchFallbackPage(path, qs, cb) || this._fetch404(file, qs, cb); } ); @@ -209,7 +209,9 @@ export function fetchMixin(proto) { return false; } - const newPath = path.replace(new RegExp(`^/${local}`), ''); + const newPath = this.router.getFile( + path.replace(new RegExp(`^/${local}`), '') + ); const req = request(newPath + qs, true, requestHeaders); req.then( diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 4eaf51215..669b6226f 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -208,14 +208,14 @@ export class Compiler { let { str, config } = getAndRemoveConfig(text); const nextToc = { level, title: str }; - if (/{docsify-ignore}/g.test(str)) { - str = str.replace('{docsify-ignore}', ''); + if (//g.test(str)) { + str = str.replace('', ''); nextToc.title = str; nextToc.ignoreSubHeading = true; } - if (/{docsify-ignore-all}/g.test(str)) { - str = str.replace('{docsify-ignore-all}', ''); + if (//g.test(str)) { + str = str.replace('', ''); nextToc.title = str; nextToc.ignoreAllSubs = true; } diff --git a/src/core/render/compiler/headline.js b/src/core/render/compiler/headline.js index 3f5c22039..cfbad7b25 100644 --- a/src/core/render/compiler/headline.js +++ b/src/core/render/compiler/headline.js @@ -6,14 +6,14 @@ export const headingCompiler = ({ renderer, router, _self }) => let { str, config } = getAndRemoveConfig(text); const nextToc = { level, title: str }; - if (/{docsify-ignore}/g.test(str)) { - str = str.replace('{docsify-ignore}', ''); + if (//g.test(str)) { + str = str.replace('', ''); nextToc.title = str; nextToc.ignoreSubHeading = true; } - if (/{docsify-ignore-all}/g.test(str)) { - str = str.replace('{docsify-ignore-all}', ''); + if (//g.test(str)) { + str = str.replace('', ''); nextToc.title = str; nextToc.ignoreAllSubs = true; } diff --git a/src/core/render/embed.js b/src/core/render/embed.js index d31cd2b02..63db66972 100644 --- a/src/core/render/embed.js +++ b/src/core/render/embed.js @@ -101,7 +101,7 @@ export function prerenderEmbed({ compiler, raw = '', fetch }, done) { const compile = compiler._marked; let tokens = compile.lexer(raw); const embedTokens = []; - const linkRE = compile.InlineLexer.rules.link; + const linkRE = compile.Lexer.rules.inline.link; const links = tokens.links; tokens.forEach((token, index) => { diff --git a/src/core/render/tpl.js b/src/core/render/tpl.js index e3b35a5c3..2bad3a311 100644 --- a/src/core/render/tpl.js +++ b/src/core/render/tpl.js @@ -91,7 +91,7 @@ export function tree(toc, tpl = '') { let innerHTML = ''; toc.forEach(node => { - innerHTML += `
  • ${node.title}
  • `; + innerHTML += `
  • ${node.title}
  • `; if (node.children) { innerHTML += tree(node.children, tpl); } diff --git a/src/core/router/history/hash.js b/src/core/router/history/hash.js index 166af9ab5..caaea4571 100644 --- a/src/core/router/history/hash.js +++ b/src/core/router/history/hash.js @@ -39,7 +39,7 @@ export class HashHistory extends History { on('click', e => { const el = e.target.tagName === 'A' ? e.target : e.target.parentNode; - if (el.tagName === 'A' && !/_blank/.test(el.target)) { + if (el && el.tagName === 'A' && !/_blank/.test(el.target)) { navigating = true; } }); diff --git a/src/plugins/search/index.js b/src/plugins/search/index.js index 3bfd3b6b5..e97c3b026 100644 --- a/src/plugins/search/index.js +++ b/src/plugins/search/index.js @@ -1,5 +1,5 @@ /* eslint-disable no-unused-vars */ -import { init as initComponet, update as updateComponent } from './component'; +import { init as initComponent, update as updateComponent } from './component'; import { init as initSearch } from './search'; const CONFIG = { @@ -10,6 +10,7 @@ const CONFIG = { maxAge: 86400000, // 1 day hideOtherSidebarContent: false, namespace: undefined, + pathNamespaces: undefined, }; const install = function(hook, vm) { @@ -27,12 +28,13 @@ const install = function(hook, vm) { CONFIG.hideOtherSidebarContent = opts.hideOtherSidebarContent || CONFIG.hideOtherSidebarContent; CONFIG.namespace = opts.namespace || CONFIG.namespace; + CONFIG.pathNamespaces = opts.pathNamespaces || CONFIG.pathNamespaces; } const isAuto = CONFIG.paths === 'auto'; hook.mounted(_ => { - initComponet(CONFIG, vm); + initComponent(CONFIG, vm); !isAuto && initSearch(CONFIG, vm); }); hook.doneEach(_ => { diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index b931e62cc..6a212c016 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -170,7 +170,10 @@ export function search(query) { '...' + escapeHtml(postContent) .substring(start, end) - .replace(regEx, `${keyword}`) + + .replace( + regEx, + word => `${word}` + ) + '...'; resultStr += matchContent; @@ -195,9 +198,29 @@ export function search(query) { export function init(config, vm) { const isAuto = config.paths === 'auto'; + const paths = isAuto ? getAllPaths(vm.router) : config.paths; + + let namespaceSuffix = ''; + + // only in auto mode + if (isAuto && config.pathNamespaces) { + const path = paths[0]; - const expireKey = resolveExpireKey(config.namespace); - const indexKey = resolveIndexKey(config.namespace); + if (Array.isArray(config.pathNamespaces)) { + namespaceSuffix = + config.pathNamespaces.find(prefix => path.startsWith(prefix)) || + namespaceSuffix; + } else if (config.pathNamespaces instanceof RegExp) { + const matches = path.match(config.pathNamespaces); + + if (matches) { + namespaceSuffix = matches[0]; + } + } + } + + const expireKey = resolveExpireKey(config.namespace) + namespaceSuffix; + const indexKey = resolveIndexKey(config.namespace) + namespaceSuffix; const isExpired = localStorage.getItem(expireKey) < Date.now(); @@ -209,7 +232,6 @@ export function init(config, vm) { return; } - const paths = isAuto ? getAllPaths(vm.router) : config.paths; const len = paths.length; let count = 0; diff --git a/test/unit/render.test.js b/test/unit/render.test.js index 28e88ac0e..43a87248d 100644 --- a/test/unit/render.test.js +++ b/test/unit/render.test.js @@ -251,6 +251,43 @@ describe('render', function() { ` ); }); + + it('ignore', async function() { + const { docsify } = await init(); + const output = docsify.compiler.compile( + '## h2 tag ' + ); + expectSameDom( + output, + ` +

    + + h2 tag + +

    ` + ); + }); + + it('ignore-all', async function() { + const { docsify } = await init(); + const output = docsify.compiler.compile( + `# h1 tag ` + `\n## h2 tag` + ); + expectSameDom( + output, + ` +

    + + h1 tag + +

    +

    + + h2 tag + +

    ` + ); + }); }); describe('link', function() {