Skip to content

Commit b75eb85

Browse files
committed
feat: filter sidebar to show frequently used endpoints\n\nImplement toggle to filter to most commonly used API endpoints.
1 parent 7c67ef6 commit b75eb85

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

components/sidebar.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ const sections: SidebarSection[] = [
8787
},
8888
]
8989

90+
const FREQUENTLY_USED_IDS = new Set([
91+
'auth',
92+
'rate-limits',
93+
'get-user',
94+
'get-repo',
95+
'list-repos',
96+
'get-readme',
97+
'list-commits',
98+
'list-issues',
99+
'list-prs',
100+
'repo-views',
101+
])
102+
90103
interface SidebarProps {
91104
selectedId?: string
92105
onSelectItem: (id: string) => void
@@ -109,12 +122,16 @@ export function Sidebar({ selectedId = 'intro', onSelectItem }: SidebarProps) {
109122
setExpandedSections(newExpanded)
110123
}
111124

112-
const filteredSections = sections
125+
const displaySections = frequentlyUsed ? sections : sections
126+
127+
const filteredSections = displaySections
113128
.map((section) => ({
114129
...section,
115-
items: section.items.filter((item) =>
116-
item.label.toLowerCase().includes(searchTerm.toLowerCase())
117-
),
130+
items: section.items.filter((item) => {
131+
const matchesSearch = item.label.toLowerCase().includes(searchTerm.toLowerCase())
132+
const isFrequent = frequentlyUsed ? FREQUENTLY_USED_IDS.has(item.id) : true
133+
return matchesSearch && isFrequent
134+
}),
118135
}))
119136
.filter(
120137
(section) =>

0 commit comments

Comments
 (0)