Skip to content

Commit 1c047a4

Browse files
authored
Merge pull request #22 from jinyang1994/main
feat: support custom collapsed state for sidebar categories
2 parents 0a42d95 + 8b69f50 commit 1c047a4

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

docs/llm-inference-basics/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
sidebar_position: 1
33
sidebar_custom_props:
44
icon: /img/book.svg
5+
collapsed: false
56
---
67

78
# LLM inference basics

docusaurus.config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,21 @@ const config: Config = {
4545
containerId: 'GTM-NLGDMK5'
4646
},
4747
docs: {
48-
routeBasePath: '/'
48+
routeBasePath: '/',
49+
sidebarItemsGenerator: async (args) => {
50+
const { defaultSidebarItemsGenerator } = args
51+
const items = await defaultSidebarItemsGenerator(args)
52+
53+
return items.map((item) => {
54+
if (item.customProps?.collapsed !== undefined) {
55+
return {
56+
...item,
57+
collapsed: Boolean(item.customProps?.collapsed)
58+
}
59+
}
60+
return item
61+
})
62+
}
4963
},
5064
theme: {
5165
customCss: './src/css/custom.css'

src/theme/NavbarItem/DropdownNavbarItem/Desktop/index.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ export default function DropdownNavbarItemDesktop({
1515
}: Props): ReactNode {
1616
const dropdownRef = useRef<HTMLDivElement>(null)
1717
const [showDropdown, setShowDropdown] = useState(false)
18-
const isCardMode = useMemo(() => {
19-
console.log(
18+
const isCardMode = useMemo(
19+
() =>
2020
items.every(
2121
(item) => item.description && item.label && item.text && item.icon
22-
)
23-
)
24-
return items.every(
25-
(item) => item.description && item.label && item.text && item.icon
26-
)
27-
}, [items])
22+
),
23+
[items]
24+
)
2825

2926
useEffect(() => {
3027
const handleClickOutside = (

0 commit comments

Comments
 (0)