Skip to content

Commit e9ac479

Browse files
committed
fix: outline should update when page change (ssg bug)
1 parent 8474183 commit e9ac479

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/theme-doc/src/Layout/Outline.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ const OutLine: React.FC<Props> = (props) => {
1616
() => pageData?.outlineInfo?.outline
1717
)
1818

19-
if (import.meta.hot) {
20-
// subscribe to outline info hmr update
21-
useEffect(() => {
22-
const cur = pageData?.outlineInfo?.outline
23-
setOutline(cur)
19+
useEffect(() => {
20+
const outlineData = pageData?.outlineInfo?.outline
21+
setOutline(outlineData)
22+
if (import.meta.hot) {
23+
// subscribe to outline info hmr update
2424
const unsub = pageData?.outlineInfo?.onUpdate?.((newMod: any) => {
2525
const cur = newMod?.outline
2626
setOutline(cur)
2727
})
2828
return () => {
2929
unsub?.()
3030
}
31-
}, [pageData])
32-
}
31+
}
32+
}, [pageData])
3333

3434
const data = useMemo(() => {
3535
// should not render OutLine if there is only one heading

0 commit comments

Comments
 (0)