From 68d873587c29d694ece466177984aa5fd739dd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?WangLiang/=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Tue, 3 Jan 2023 15:46:50 +0800 Subject: [PATCH 1/7] fix: genIndex error for search (#1933) --- src/plugins/search/search.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 3266b7bb4..f8d7cd3ab 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -128,9 +128,7 @@ export function genIndex(path, content = '', router, depth) { token.text = getTableData(token); token.text = getListData(token); - index[slug].body = index[slug].body - ? index[slug].body + token.text - : token.text; + index[slug].body = token.text || ''; } } }); From 6a7d15b1d5b93e19d3cf9a328cdbf5f1a166b5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Sun, 18 Jun 2023 11:51:32 +0800 Subject: [PATCH 2/7] fix: enhancement of isExternal (#2093) --- src/core/util/core.js | 3 +++ test/unit/core-util.test.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/core/util/core.js b/src/core/util/core.js index 985a0e829..e1e585d53 100644 --- a/src/core/util/core.js +++ b/src/core/util/core.js @@ -96,5 +96,8 @@ export function isExternal(url) { ) { return true; } + if (/^\/\\/.test(url)) { + return true; + } return false; } diff --git a/test/unit/core-util.test.js b/test/unit/core-util.test.js index 0ebbf7bbd..a6ff7d3ef 100644 --- a/test/unit/core-util.test.js +++ b/test/unit/core-util.test.js @@ -59,5 +59,17 @@ describe('core/util', () => { expect(result).toBeTruthy(); }); + + test('external url with one \\', () => { + const result = isExternal('/\\example.github.io/docsify/demo.md'); + + expect(result).toBeTruthy(); + }); + + test('external url with two \\', () => { + const result = isExternal('/\\\\example.github.io/docsify/demo.md'); + + expect(result).toBeTruthy(); + }); }); }); From 2312feef459211a8bcdcbf9164a9ffe051609b70 Mon Sep 17 00:00:00 2001 From: Joe Pea Date: Sun, 22 Jan 2023 09:54:30 -0800 Subject: [PATCH 3/7] fix: fix cross-origin links in history router mode (#1967) --- docs/configuration.md | 30 +++++++++--------------------- docs/helpers.md | 8 -------- src/core/config.js | 1 - src/core/render/compiler/link.js | 11 ----------- src/core/router/history/hash.js | 4 ++-- src/core/router/history/html5.js | 11 +++-------- 6 files changed, 14 insertions(+), 51 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 3fdf2a61c..61c3a9b3e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -140,19 +140,6 @@ window.$docsify = { }; ``` -## crossOriginLinks - -- Type: `Array` - -When `routerMode: 'history'`, you may face cross-origin issues. See [#1379](https://github.com/docsifyjs/docsify/issues/1379). -In Markdown content, there is a simple way to solve it: see extends Markdown syntax `Cross-Origin link` in [helpers](helpers.md). - -```js -window.$docsify = { - crossOriginLinks: ['https://example.com/cross-origin-link'], -}; -``` - ## el - Type: `String` @@ -688,6 +675,7 @@ window.$docsify = { Define "virtual" routes that can provide content dynamically. A route is a map between the expected path, to either a string or a function. If the mapped value is a string, it is treated as markdown and parsed accordingly. If it is a function, it is expected to return markdown content. A route function receives up to three parameters: + 1. `route` - the path of the route that was requested (e.g. `/bar/baz`) 2. `matched` - the [`RegExpMatchArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) that was matched by the route (e.g. for `/bar/(.+)`, you get `['/bar/baz', 'baz']`) 3. `next` - this is a callback that you may call when your route function is async @@ -701,23 +689,23 @@ window.$docsify = { '/foo': '# Custom Markdown', // RegEx match w/ synchronous function - '/bar/(.*)': function(route, matched) { + '/bar/(.*)': function (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/(.*)': function (route, matched, next) { + // Requires `fetch` polyfill for legacy browsers (https://github.github.io/fetch/) fetch('/api/users?id=12345') - .then(function(response) { + .then(function (response) { next('# Custom Markdown'); }) - .catch(function(err) { + .catch(function (err) { // Handle error... }); - } - } -} + }, + }, +}; ``` Other than strings, route functions can return a falsy value (`null` \ `undefined`) to indicate that they ignore the current request: diff --git a/docs/helpers.md b/docs/helpers.md index 6bd8a069d..a6fc95ea5 100644 --- a/docs/helpers.md +++ b/docs/helpers.md @@ -65,14 +65,6 @@ You will get `link`html. Do not worry, you can still set th [link](/demo ':disabled') ``` -## Cross-Origin link - -Only when you set both the `routerMode: 'history'` and `externalLinkTarget: '_self'`, you need to add this configuration for those Cross-Origin links. - -```md -[example.com](https://example.com/ ':crossorgin') -``` - ## GitHub Task Lists ```md diff --git a/src/core/config.js b/src/core/config.js index 5dc9a3850..9a8bdb2f8 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -12,7 +12,6 @@ export default function (vm) { catchPluginErrors: true, cornerExternalLinkTarget: '_blank', coverpage: '', - crossOriginLinks: [], el: '#app', executeScript: null, ext: '.md', diff --git a/src/core/render/compiler/link.js b/src/core/render/compiler/link.js index fd8b81138..613101000 100644 --- a/src/core/render/compiler/link.js +++ b/src/core/render/compiler/link.js @@ -43,17 +43,6 @@ export const linkCompiler = ({ ); } - // special case to check crossorigin urls - if ( - config.crossorgin && - linkTarget === '_self' && - compilerClass.config.routerMode === 'history' - ) { - if (compilerClass.config.crossOriginLinks.indexOf(href) === -1) { - compilerClass.config.crossOriginLinks.push(href); - } - } - if (config.disabled) { attrs.push('disabled'); href = 'javascript:void(0)'; diff --git a/src/core/router/history/hash.js b/src/core/router/history/hash.js index abb060f2f..05435d2c9 100644 --- a/src/core/router/history/hash.js +++ b/src/core/router/history/hash.js @@ -1,4 +1,4 @@ -import { noop } from '../../util/core'; +import { isExternal, noop } from '../../util/core'; import { on } from '../../util/dom'; import { endsWith } from '../../util/str'; import { parseQuery, cleanPath, replaceSlug } from '../util'; @@ -48,7 +48,7 @@ export class HashHistory extends History { on('click', e => { const el = e.target.tagName === 'A' ? e.target : e.target.parentNode; - if (el && el.tagName === 'A' && !/_blank/.test(el.target)) { + if (el && el.tagName === 'A' && !isExternal(el.href)) { navigating = true; } }); diff --git a/src/core/router/history/html5.js b/src/core/router/history/html5.js index eeadb1af1..1304d0628 100644 --- a/src/core/router/history/html5.js +++ b/src/core/router/history/html5.js @@ -1,4 +1,4 @@ -import { noop } from '../../util/core'; +import { isExternal, noop } from '../../util/core'; import { on } from '../../util/dom'; import { parseQuery, getPath } from '../util'; import { History } from './base'; @@ -24,15 +24,10 @@ export class HTML5History extends History { on('click', e => { const el = e.target.tagName === 'A' ? e.target : e.target.parentNode; - if (el && el.tagName === 'A' && !/_blank/.test(el.target)) { + if (el && el.tagName === 'A' && !isExternal(el.href)) { e.preventDefault(); const url = el.href; - // solve history.pushState cross-origin issue - if (this.config.crossOriginLinks.indexOf(url) !== -1) { - window.open(url, '_self'); - } else { - window.history.pushState({ key: url }, '', url); - } + window.history.pushState({ key: url }, '', url); cb({ event: e, source: 'navigate' }); } }); From 00580a4c6bac6f84f1b4f6b65f32f5099cab5cea Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 24 Jun 2023 15:24:08 +0800 Subject: [PATCH 4/7] chore: sync emojis --- docs/emoji.md | 6 ++++++ src/core/render/emoji-data.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/docs/emoji.md b/docs/emoji.md index 4f198414c..3b562fadc 100644 --- a/docs/emoji.md +++ b/docs/emoji.md @@ -34,6 +34,8 @@ Below is a complete list of emoji shorthand codes. Docsify can be configured to :accept: `:accept:` +:accessibility: `:accessibility:` + :accordion: `:accordion:` :adhesive_bandage: `:adhesive_bandage:` @@ -920,6 +922,8 @@ Below is a complete list of emoji shorthand codes. Docsify can be configured to :department_store: `:department_store:` +:dependabot: `:dependabot:` + :derelict_house: `:derelict_house:` :desert: `:desert:` @@ -1238,6 +1242,8 @@ Below is a complete list of emoji shorthand codes. Docsify can be configured to :fishing_pole_and_fish: `:fishing_pole_and_fish:` +:fishsticks: `:fishsticks:` + :fist: `:fist:` :fist_left: `:fist_left:` diff --git a/src/core/render/emoji-data.js b/src/core/render/emoji-data.js index c9494fca0..b065d0873 100644 --- a/src/core/render/emoji-data.js +++ b/src/core/render/emoji-data.js @@ -21,6 +21,7 @@ export default { "abc": "unicode/1f524.png?v8", "abcd": "unicode/1f521.png?v8", "accept": "unicode/1f251.png?v8", + "accessibility": "accessibility.png?v8", "accordion": "unicode/1fa97.png?v8", "adhesive_bandage": "unicode/1fa79.png?v8", "adult": "unicode/1f9d1.png?v8", @@ -464,6 +465,7 @@ export default { "deer": "unicode/1f98c.png?v8", "denmark": "unicode/1f1e9-1f1f0.png?v8", "department_store": "unicode/1f3ec.png?v8", + "dependabot": "dependabot.png?v8", "derelict_house": "unicode/1f3da.png?v8", "desert": "unicode/1f3dc.png?v8", "desert_island": "unicode/1f3dd.png?v8", @@ -623,6 +625,7 @@ export default { "fish": "unicode/1f41f.png?v8", "fish_cake": "unicode/1f365.png?v8", "fishing_pole_and_fish": "unicode/1f3a3.png?v8", + "fishsticks": "fishsticks.png?v8", "fist": "unicode/270a.png?v8", "fist_left": "unicode/1f91b.png?v8", "fist_oncoming": "unicode/1f44a.png?v8", From a7b8a5ecdf7b2ee24d04bc24d8d7d932755d34ef Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 24 Jun 2023 15:25:52 +0800 Subject: [PATCH 5/7] [build] 4.13.1 --- docs/_coverpage.md | 2 +- packages/docsify-server-renderer/package-lock.json | 2 +- packages/docsify-server-renderer/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/_coverpage.md b/docs/_coverpage.md index af2d706b5..a67b986f0 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](_media/icon.svg) -# docsify 4.13.0 +# docsify 4.13.1 > A magical documentation site generator. diff --git a/packages/docsify-server-renderer/package-lock.json b/packages/docsify-server-renderer/package-lock.json index 0c077d906..eb7001bf3 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.13.0", + "version": "4.13.1", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/packages/docsify-server-renderer/package.json b/packages/docsify-server-renderer/package.json index 44e12cfac..3601f2a15 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.13.0", + "version": "4.13.1", "description": "docsify server renderer", "author": { "name": "qingwei-li", From 862b10053879386a48ab34c21d7ca648483be738 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 24 Jun 2023 15:25:54 +0800 Subject: [PATCH 6/7] chore: add changelog 4.13.1 --- CHANGELOG.md | 11 +++++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38b3fa6ce..4078c4647 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [4.13.1](https://github.com/docsifyjs/docsify/compare/v4.13.0...v4.13.1) (2023-06-24) + + +### Bug Fixes + +* enhancement of isExternal ([#2093](https://github.com/docsifyjs/docsify/issues/2093)) ([6a7d15b](https://github.com/docsifyjs/docsify/commit/6a7d15b1d5b93e19d3cf9a328cdbf5f1a166b5bd)) +* fix cross-origin links in history router mode ([#1967](https://github.com/docsifyjs/docsify/issues/1967)) ([2312fee](https://github.com/docsifyjs/docsify/commit/2312feef459211a8bcdcbf9164a9ffe051609b70)) +* genIndex error for search ([#1933](https://github.com/docsifyjs/docsify/issues/1933)) ([68d8735](https://github.com/docsifyjs/docsify/commit/68d873587c29d694ece466177984aa5fd739dd4b)) + + + # [4.13.0](https://github.com/docsifyjs/docsify/compare/v4.12.4...v4.13.0) (2022-10-26) diff --git a/package-lock.json b/package-lock.json index ca11673a6..198fd1cd2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "docsify", - "version": "4.13.0", + "version": "4.13.1", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 6c2dbbcc4..79868e2a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docsify", - "version": "4.13.0", + "version": "4.13.1", "description": "A magical documentation generator.", "author": { "name": "qingwei-li", From 141ac96add9892fcb345551906770c4e9b2265b0 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 24 Jun 2023 15:32:04 +0800 Subject: [PATCH 7/7] chore: update integration snapshots --- test/integration/__snapshots__/docs.test.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/__snapshots__/docs.test.js.snap b/test/integration/__snapshots__/docs.test.js.snap index ae415aa46..002ae85bc 100644 --- a/test/integration/__snapshots__/docs.test.js.snap +++ b/test/integration/__snapshots__/docs.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Docs Site coverpage renders and is unchanged 1`] = ` -"

\\"logo\\"

docsify 4.13.0

+"

\\"logo\\"

docsify 4.13.1

A magical documentation site generator.

  • Simple and lightweight
  • No statically built html files
  • Multiple themes

GitHub Getting Started

"