File tree 1 file changed +17
-4
lines changed
packages/gitbook/src/components/SitePage
1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -66,17 +66,30 @@ async function resolvePage(context: GitBookSiteContext, params: PagePathParams |
66
66
return resolvePageId ( pages , resolved . id ) ;
67
67
}
68
68
69
- // If a page still can't be found, we try with the API, in case we have a redirect at site level.
70
- const resolvedSiteRedirect = await getDataOrNull (
69
+ // We first try to resovle a site redirect with the full path
70
+ const resolvedSiteRedirectFull = await getDataOrNull (
71
+ context . dataFetcher . getSiteRedirectBySource ( {
72
+ organizationId,
73
+ siteId : site . id ,
74
+ source : context . linker . toPathInContent ( rawPathname ) ,
75
+ siteShareKey : shareKey ,
76
+ } )
77
+ ) ;
78
+ if ( resolvedSiteRedirectFull ) {
79
+ return redirect ( resolvedSiteRedirectFull . target ) ;
80
+ }
81
+
82
+ // If a page still can't be found, we try to resolve a site redirect with the partial path
83
+ const resolvedSiteRedirectPartial = await getDataOrNull (
71
84
context . dataFetcher . getSiteRedirectBySource ( {
72
85
organizationId,
73
86
siteId : site . id ,
74
87
source : rawPathname . startsWith ( '/' ) ? rawPathname : `/${ rawPathname } ` ,
75
88
siteShareKey : shareKey ,
76
89
} )
77
90
) ;
78
- if ( resolvedSiteRedirect ) {
79
- return redirect ( resolvedSiteRedirect . target ) ;
91
+ if ( resolvedSiteRedirectPartial ) {
92
+ return redirect ( resolvedSiteRedirectPartial . target ) ;
80
93
}
81
94
}
82
95
You can’t perform that action at this time.
0 commit comments