Skip to content

Commit 79f2d8b

Browse files
authored
Refactor getContentPointer usage into getSiteContentPointer (#2519)
1 parent 7b1bdb9 commit 79f2d8b

39 files changed

+238
-238
lines changed

bun.lockb

0 Bytes
Binary file not shown.

packages/gitbook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static"
1717
},
1818
"dependencies": {
19-
"@gitbook/api": "0.60.0",
19+
"@gitbook/api": "0.64.1",
2020
"@gitbook/cache-do": "workspace:*",
2121
"@gitbook/emoji-codepoints": "workspace:*",
2222
"@gitbook/icons": "workspace:*",

packages/gitbook/src/app/(space)/(content)/[[...pathname]]/not-found.tsx renamed to packages/gitbook/src/app/(site)/(content)/[[...pathname]]/not-found.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { getSpaceLanguage, t } from '@/intl/server';
22
import { getSiteLayoutData, getSpaceLayoutData } from '@/lib/api';
3+
import { getSiteContentPointer } from '@/lib/pointer';
34
import { tcls } from '@/lib/tailwind';
45

5-
import { getContentPointer } from '../../fetch';
6-
76
export default async function NotFound() {
8-
const pointer = getContentPointer();
9-
const { customization } = await ('siteId' in pointer
10-
? getSiteLayoutData(pointer)
11-
: getSpaceLayoutData(pointer.spaceId));
7+
const pointer = getSiteContentPointer();
8+
const { customization } = await getSiteLayoutData(pointer);
129

1310
const language = getSpaceLanguage(customization);
1411

packages/gitbook/src/app/(space)/(content)/[[...pathname]]/page.tsx renamed to packages/gitbook/src/app/(site)/(content)/[[...pathname]]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default async function Page(props: {
6565
const withPageFeedback = customization.feedback.enabled;
6666

6767
const contentRefContext: ContentRefContext = {
68-
siteContext: 'siteId' in contentPointer ? contentPointer : null,
68+
siteContext: contentPointer,
6969
space,
7070
revisionId: contentTarget.revisionId,
7171
pages,
@@ -80,7 +80,7 @@ export default async function Page(props: {
8080
<div className={tcls('flex', 'flex-row')}>
8181
<PageBody
8282
space={space}
83-
contentPointer={contentPointer}
83+
pointer={contentPointer}
8484
contentTarget={contentTarget}
8585
customization={customization}
8686
context={contentRefContext}

packages/gitbook/src/app/(space)/(core)/robots.txt/route.ts renamed to packages/gitbook/src/app/(site)/(core)/robots.txt/route.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ import { NextRequest } from 'next/server';
33

44
import { getCollection, getSite, getSpace } from '@/lib/api';
55
import { absoluteHref } from '@/lib/links';
6+
import { getSiteContentPointer } from '@/lib/pointer';
67
import { isSpaceIndexable } from '@/lib/seo';
78

8-
import { getContentPointer } from '../../fetch';
9-
109
export const runtime = 'edge';
1110

1211
/**
1312
* Generate a robots.txt for the current space.
1413
*/
1514
export async function GET(req: NextRequest) {
16-
const pointer = getContentPointer();
17-
const space = await getSpace(
18-
pointer.spaceId,
19-
'siteId' in pointer ? pointer.siteShareKey : undefined,
20-
);
21-
const site = 'siteId' in pointer ? await getSite(pointer.organizationId, pointer.siteId) : null;
15+
const pointer = getSiteContentPointer();
16+
const [site, space] = await Promise.all([
17+
getSite(pointer.organizationId, pointer.siteId),
18+
getSpace(pointer.spaceId, pointer.siteShareKey),
19+
]);
2220

2321
const lines = [
2422
`User-agent: *`,

0 commit comments

Comments
 (0)