docs: fix sidebar items not showing if they have same title in API reference (#11122)
This commit is contained in:
1 parent
dc3a4b5c40
commit
8038a917ee
5 files changed
+19
-20
No files matched your search
@@ -21,6 +21,7 @@ import {
|
||||
InteractiveSidebarItem,
|
||||
SidebarItemCategory,
|
||||
SidebarItemLinkWithParent,
|
||||
SidebarItemTypes,
|
||||
} from "types"
|
||||
import { useIsBrowser } from "../BrowserProvider"
|
||||
|
||||
@@ -70,6 +71,7 @@ export const SidebarContext = createContext<SidebarContextType | null>(null)
|
||||
export type ActionOptionsType = {
|
||||
section?: SidebarItemSections
|
||||
parent?: {
|
||||
type: SidebarItemTypes
|
||||
path: string
|
||||
title: string
|
||||
changeLoaded?: boolean
|
||||
@@ -106,17 +108,20 @@ export const isSidebarItemLink = (
|
||||
}
|
||||
|
||||
const areItemsEqual = (itemA: SidebarItem, itemB: SidebarItem): boolean => {
|
||||
if (itemA.type === "separator" || itemB.type === "separator") {
|
||||
if (
|
||||
itemA.type === "separator" ||
|
||||
itemB.type === "separator" ||
|
||||
itemA.type !== itemB.type
|
||||
) {
|
||||
return false
|
||||
}
|
||||
const hasSameTitle = itemA.title === itemB.title
|
||||
const hasSamePath =
|
||||
isSidebarItemLink(itemA) &&
|
||||
isSidebarItemLink(itemB) &&
|
||||
itemA.type === itemB.type &&
|
||||
!isSidebarItemLink(itemA) ||
|
||||
!isSidebarItemLink(itemB) ||
|
||||
itemA.path === itemB.path
|
||||
|
||||
return hasSameTitle || hasSamePath
|
||||
return hasSameTitle && hasSamePath
|
||||
}
|
||||
|
||||
const findItem = (
|
||||
|
||||
@@ -17,6 +17,8 @@ export type SidebarItemCommon = {
|
||||
description?: string
|
||||
}
|
||||
|
||||
export type SidebarItemTypes = "category" | "sub-category" | "link" | "ref"
|
||||
|
||||
export type SidebarItemLink = SidebarItemCommon & {
|
||||
type: "link" | "ref"
|
||||
path: string
|
||||
|
||||
Reference in new issue
Block a user