Fix resolution of links in reusable content (#3212)

This commit is contained in:
Samy Pessé
2025-05-06 10:30:55 +02:00
committed by GitHub
parent 04999662db
commit 5d504ffa4c
2 changed files with 20 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Fix resolution of links in reusable contents
@@ -46,14 +46,21 @@ export async function ReusableContent(props: BlockProps<DocumentBlockReusableCon
// Create a new context for reusable content block, including
// the data fetcher with the token from the block meta and the correct
// space and revision pointers.
const reusableContentContext: GitBookSpaceContext = {
...context.contentContext,
dataFetcher,
space: resolved.reusableContent.space,
revisionId: resolved.reusableContent.revision,
pages: [],
shareKey: undefined,
};
const reusableContentContext: GitBookSpaceContext =
context.contentContext.space.id === resolved.reusableContent.space.id
? context.contentContext
: {
...context.contentContext,
dataFetcher,
space: resolved.reusableContent.space,
revisionId: resolved.reusableContent.revision,
// When the reusable content is in a different space, we don't resolve relative links to pages
// as this space might not be part of the current site.
// In the future, we might expand the logic to look up the space from the list of all spaces in the site
// and adapt the relative links to point to the correct variant.
pages: [],
shareKey: undefined,
};
return (
<UnwrappedBlocks