Skip to content

Commit 504fe1f

Browse files
committed
fix: update TOC item access in DocTemplate component
- Modified the condition for accessing TOC items to ensure it handles undefined cases correctly. - Updated the dependency array in the useMemo hook to include the entire toc object for better stability in TOC data generation.
1 parent fb132fa commit 504fe1f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/templates/DocTemplate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ function DocTemplate({
145145
const pageType = getPageType(language, pageUrl);
146146
const rightTocData: TableOfContent[] | undefined = React.useMemo(() => {
147147
let tocItems: TableOfContent[] = [];
148-
if (toc.items?.length === 1) {
148+
if (toc?.items?.length === 1) {
149149
tocItems = toc.items![0].items || [];
150150
} else {
151151
tocItems = toc.items || [];
152152
}
153153

154154
// Filter TOC based on CustomContent conditions
155155
return filterRightToc(tocItems, pageType, cloudPlan, language);
156-
}, [toc.items, pageType, cloudPlan, language]);
156+
}, [toc, pageType, cloudPlan, language]);
157157

158158
const stableBranch = getStable(pathConfig.repo);
159159

0 commit comments

Comments
 (0)