Skip to content

Commit

Permalink
feat: use vm.router.toURL, deprecate routerMode option
Browse files Browse the repository at this point in the history
  • Loading branch information
imyelo committed Jun 24, 2022
1 parent a882f4f commit 59dd5f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 2 additions & 9 deletions src/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 59dd5f1

Please sign in to comment.