Skip to content

Commit 59dd5f1

Browse files
committed
feat: use vm.router.toURL, deprecate routerMode option
1 parent a882f4f commit 59dd5f1

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
* **Type:** ``Boolean``
5555
* **Description:** Display chapter name.
5656

57-
### pagination.routerMode
57+
### ~~pagination.routerMode~~
58+
* **Deprecated**
5859
* **Default:** [`window.$docsify.routerMode`](https://docsify.js.org/#/configuration?id=routermode)
5960
* **Type:** ``String``
6061
* **Description:** Router mode. In most cases, you don't need to modify it. Docsify-Pagination will take care of it for you.

src/pagination.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@ import './stylesheet.css'
66
/**
77
* constants
88
*/
9-
const ROUTER_MODE = {
10-
HASH: 'hash',
11-
HISTORY: 'history',
12-
}
139
const DEFAULT_OPTIONS = (config) => ({
1410
previousText: 'PREVIOUS',
1511
nextText: 'NEXT',
1612
crossChapter: false,
1713
crossChapterText: false,
18-
routerMode: config.routerMode || ROUTER_MODE.HASH,
1914
})
2015
const CONTAINER_CLASSNAME = 'docsify-pagination-container'
2116

@@ -69,11 +64,9 @@ class Link {
6964
}
7065
}
7166

72-
function pagination (vm, { crossChapter, routerMode }) {
67+
function pagination (vm, { crossChapter }) {
7368
try {
74-
const path = routerMode === ROUTER_MODE.HISTORY ?
75-
vm.route.path :
76-
`#${vm.route.path}`
69+
const path = vm.router.toURL(vm.route.path)
7770
const all = toArray(query.all('.sidebar-nav li a')).filter((element) => !matches(element, '.section-link'))
7871
const active = all.find(isALinkTo(path))
7972
const group = toArray((closest(active, 'ul') || {}).children)

0 commit comments

Comments
 (0)