File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed
packages/gitbook/src/components/DocumentView Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " gitbook " : patch
3
+ ---
4
+
5
+ Fix resolution of links in reusable contents
Original file line number Diff line number Diff line change @@ -46,14 +46,21 @@ export async function ReusableContent(props: BlockProps<DocumentBlockReusableCon
46
46
// Create a new context for reusable content block, including
47
47
// the data fetcher with the token from the block meta and the correct
48
48
// space and revision pointers.
49
- const reusableContentContext : GitBookSpaceContext = {
50
- ...context . contentContext ,
51
- dataFetcher,
52
- space : resolved . reusableContent . space ,
53
- revisionId : resolved . reusableContent . revision ,
54
- pages : [ ] ,
55
- shareKey : undefined ,
56
- } ;
49
+ const reusableContentContext : GitBookSpaceContext =
50
+ context . contentContext . space . id === resolved . reusableContent . space . id
51
+ ? context . contentContext
52
+ : {
53
+ ...context . contentContext ,
54
+ dataFetcher,
55
+ space : resolved . reusableContent . space ,
56
+ revisionId : resolved . reusableContent . revision ,
57
+ // When the reusable content is in a different space, we don't resolve relative links to pages
58
+ // as this space might not be part of the current site.
59
+ // In the future, we might expand the logic to look up the space from the list of all spaces in the site
60
+ // and adapt the relative links to point to the correct variant.
61
+ pages : [ ] ,
62
+ shareKey : undefined ,
63
+ } ;
57
64
58
65
return (
59
66
< UnwrappedBlocks
You can’t perform that action at this time.
0 commit comments