Fix href being empty in TOC (#3269)

Co-authored-by: Nicolas Dorseuil <nicolas@gitbook.io>
This commit is contained in:
conico974
2025-05-28 17:07:33 +02:00
committed by GitHub
parent 2932077bf9
commit b3a7ad6d2c
2 changed files with 10 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
fix href being empty in TOC
@@ -17,7 +17,11 @@ export async function PageDocumentItem(props: {
context: GitBookSiteContext;
}) {
const { rootPages, page, context } = props;
const href = context.linker.toPathForPage({ pages: rootPages, page });
let href = context.linker.toPathForPage({ pages: rootPages, page });
// toPathForPage can returns an empty path, this will cause all links to point to the current page.
if (href === '') {
href = '/';
}
return (
<li className="flex flex-col">