Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-keys-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/doom": patch
---

fix: overview matching logic
16 changes: 3 additions & 13 deletions src/runtime/components/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import type {
SidebarItem,
SidebarSectionHeader,
} from '@rspress/core'
import {
isEqualPath,
normalizeHrefInRuntime as normalizeHref,
usePageData,
useSidebar,
} from '@rspress/core/runtime'
import { isEqualPath, usePageData, useSidebar } from '@rspress/core/runtime'
import { Link, renderInlineMarkdown } from '@rspress/core/theme'
import type { Header, NormalizedSidebarGroup } from '@rspress/shared'
import { Fragment, useCallback, useMemo } from 'react'
Expand Down Expand Up @@ -68,8 +63,6 @@ export function Overview(props: {

const subFilter = useCallback(
(link: string) =>
// sidebar items link without base path
// pages route path with base path
link.startsWith(routePath.replace(/overview$/, '')) &&
!isEqualPath(link, routePath),
[routePath],
Expand Down Expand Up @@ -231,10 +224,7 @@ export function Overview(props: {
{group.items.map((item) => (
<div className={classes.overviewGroup} key={item.link}>
<h3 style={{ marginBottom: 8 }}>
<Link
href={normalizeHref(item.link)}
{...renderInlineMarkdown(item.text)}
/>
<Link href={item.link} {...renderInlineMarkdown(item.text)} />
</h3>
<div className={classes.overviewDescription}>
{item.description}
Expand All @@ -248,7 +238,7 @@ export function Overview(props: {
} first:rp-mt-2`}
>
<Link
href={`${normalizeHref(item.link)}#${header.id}`}
href={`${item.link}#${header.id}`}
{...renderInlineMarkdown(header.text)}
/>
</li>
Expand Down
7 changes: 2 additions & 5 deletions src/runtime/components/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import type {
SidebarItem,
SidebarSectionHeader,
} from '@rspress/core'
import type { NormalizedSidebarGroup } from '@rspress/shared'
import { normalizeHref, type NormalizedSidebarGroup } from '@rspress/shared'

function removeIndex(link: string) {
if (link.endsWith('/index')) {
return link.slice(0, -5)
}
return link
return normalizeHref(link, true)
}

export const isSidebarDivider = (
Expand Down
Loading