mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
parent
5a73b59297
commit
d2b4654ae3
@ -38,7 +38,8 @@ const textTag = computed(() => {
|
|||||||
|
|
||||||
const itemRole = computed(() => (isLink.value ? undefined : 'button'))
|
const itemRole = computed(() => (isLink.value ? undefined : 'button'))
|
||||||
|
|
||||||
const isSeparator = computed(() => item.link?.startsWith('---'))
|
const SEPARATOR_RE = /^-{3,}$/
|
||||||
|
const isSeparator = computed(() => item.link && SEPARATOR_RE.test(item.link))
|
||||||
|
|
||||||
const classes = computed(() => [
|
const classes = computed(() => [
|
||||||
[`level-${depth}`],
|
[`level-${depth}`],
|
||||||
|
|||||||
@ -14,6 +14,8 @@ interface UsePrevNextResult {
|
|||||||
next: ComputedRef<NavItemWithLink | null>
|
next: ComputedRef<NavItemWithLink | null>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SEPARATOR_RE = /^-{3,}$/
|
||||||
|
|
||||||
export function usePrevNext(): UsePrevNextResult {
|
export function usePrevNext(): UsePrevNextResult {
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { frontmatter, theme } = useData()
|
const { frontmatter, theme } = useData()
|
||||||
@ -100,10 +102,13 @@ function flatSidebar(sidebar: ThemeSidebarItem[], res: NavItemWithLink[] = []):
|
|||||||
* Resolve `prev` or `next` config from sidebar items
|
* Resolve `prev` or `next` config from sidebar items
|
||||||
*/
|
*/
|
||||||
function resolveFromSidebarItems(sidebarItems: NavItemWithLink[], currentPath: string, offset: number): null | NavItemWithLink {
|
function resolveFromSidebarItems(sidebarItems: NavItemWithLink[], currentPath: string, offset: number): null | NavItemWithLink {
|
||||||
const index = sidebarItems.findIndex(item => resolveRouteFullPath(item.link) === currentPath)
|
let index = sidebarItems.findIndex(item => resolveRouteFullPath(item.link) === currentPath)
|
||||||
if (index !== -1) {
|
if (index === -1)
|
||||||
const targetItem = sidebarItems[index + offset]
|
return null
|
||||||
if (targetItem?.link) {
|
// eslint-disable-next-line no-cond-assign
|
||||||
|
while ((index += offset) >= 0) {
|
||||||
|
const targetItem = sidebarItems[index]
|
||||||
|
if (targetItem?.link && !SEPARATOR_RE.test(targetItem.link)) {
|
||||||
return targetItem
|
return targetItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user