mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79ce105caa |
@@ -19,7 +19,7 @@ export type RouteLayoutParams = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type RouteParams = RouteLayoutParams & {
|
export type RouteParams = RouteLayoutParams & {
|
||||||
pagePath: string;
|
pagePath?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,8 +80,10 @@ export async function getDynamicSiteContext(params: RouteLayoutParams) {
|
|||||||
* Get the decoded page path from the params.
|
* Get the decoded page path from the params.
|
||||||
*/
|
*/
|
||||||
export function getPagePathFromParams(params: RouteParams) {
|
export function getPagePathFromParams(params: RouteParams) {
|
||||||
const decoded = decodeURIComponent(params.pagePath);
|
if (!params.pagePath || params.pagePath.length === 0) {
|
||||||
return decoded;
|
return '';
|
||||||
|
}
|
||||||
|
return params.pagePath.map((part) => decodeURIComponent(part)).join('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSiteURLFromParams(params: RouteLayoutParams) {
|
function getSiteURLFromParams(params: RouteLayoutParams) {
|
||||||
|
|||||||
@@ -589,12 +589,10 @@ function encodePathInSiteContent(rawPathname: string): {
|
|||||||
return { pathname, routeType: 'static' };
|
return { pathname, routeType: 'static' };
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the pathname is an embedded page
|
// If the pathname is an embedded page, let the optional catch-all route [[...pagePath]] handle it
|
||||||
const embedPage = pathname.match(/^~gitbook\/embed\/page\/(\S+)$/);
|
// This naturally supports both empty paths (~gitbook/embed/page) and paths with segments
|
||||||
if (embedPage) {
|
if (pathname.match(/^~gitbook\/embed\/page(\/.*)?$/)) {
|
||||||
return {
|
return { pathname };
|
||||||
pathname: `~gitbook/embed/page/${encodeURIComponent(embedPage[1]!)}`,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pathname) {
|
switch (pathname) {
|
||||||
|
|||||||
Reference in New Issue
Block a user