From 59dd5f1882b44148cd357fccb7c2bc2a15ff367f Mon Sep 17 00:00:00 2001 From: Yelo Date: Fri, 24 Jun 2022 17:44:26 +0800 Subject: [PATCH] feat: use vm.router.toURL, deprecate routerMode option --- readme.md | 3 ++- src/pagination.js | 11 ++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index 683b5da..20ee6f2 100644 --- a/readme.md +++ b/readme.md @@ -54,7 +54,8 @@ * **Type:** ``Boolean`` * **Description:** Display chapter name. -### pagination.routerMode +### ~~pagination.routerMode~~ +* **Deprecated** * **Default:** [`window.$docsify.routerMode`](https://docsify.js.org/#/configuration?id=routermode) * **Type:** ``String`` * **Description:** Router mode. In most cases, you don't need to modify it. Docsify-Pagination will take care of it for you. diff --git a/src/pagination.js b/src/pagination.js index 4ac7929..3efcdb0 100644 --- a/src/pagination.js +++ b/src/pagination.js @@ -6,16 +6,11 @@ import './stylesheet.css' /** * constants */ -const ROUTER_MODE = { - HASH: 'hash', - HISTORY: 'history', -} const DEFAULT_OPTIONS = (config) => ({ previousText: 'PREVIOUS', nextText: 'NEXT', crossChapter: false, crossChapterText: false, - routerMode: config.routerMode || ROUTER_MODE.HASH, }) const CONTAINER_CLASSNAME = 'docsify-pagination-container' @@ -69,11 +64,9 @@ class Link { } } -function pagination (vm, { crossChapter, routerMode }) { +function pagination (vm, { crossChapter }) { try { - const path = routerMode === ROUTER_MODE.HISTORY ? - vm.route.path : - `#${vm.route.path}` + const path = vm.router.toURL(vm.route.path) const all = toArray(query.all('.sidebar-nav li a')).filter((element) => !matches(element, '.section-link')) const active = all.find(isALinkTo(path)) const group = toArray((closest(active, 'ul') || {}).children)