Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some places where the GitBook space wasn't required, reducing some async deps. #2762

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove some places where the GitBook space wasn't required, reducing …
…some async deps.
  • Loading branch information
emmerich committed Jan 21, 2025
commit 4bd2aa1dfd1112e633d272bbe79b3a355716234f
Original file line number Diff line number Diff line change
@@ -169,8 +169,7 @@ export async function generateMetadata({
],
},
robots:
(await isSpaceIndexable({ space, site: site ?? null })) &&
isPageIndexable(ancestors, page)
(await isSpaceIndexable(site ?? null)) && isPageIndexable(ancestors, page)
? 'index, follow'
: 'noindex, nofollow',
};
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ export async function generateMetadata(): Promise<Metadata> {
},
],
},
robots: (await isSpaceIndexable({ space, site })) ? 'index, follow' : 'noindex, nofollow',
robots: (await isSpaceIndexable(site)) ? 'index, follow' : 'noindex, nofollow',
};
}

Original file line number Diff line number Diff line change
@@ -12,15 +12,12 @@ export const runtime = 'edge';
*/
export async function GET(req: NextRequest) {
const pointer = await getSiteContentPointer();
const [site, space] = await Promise.all([
getSite(pointer.organizationId, pointer.siteId),
getSpace(pointer.spaceId, pointer.siteShareKey),
]);
const site = await getSite(pointer.organizationId, pointer.siteId);

const lines = [
`User-agent: *`,
'Disallow: /~gitbook/',
...((await isSpaceIndexable({ space, site }))
...((await isSpaceIndexable(site))
? [`Allow: /`, `Sitemap: ${await getAbsoluteHref(`/sitemap.xml`, true)}`]
: [`Disallow: /`]),
];
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import { resolvePageId } from '@/lib/pages';
import { ContentRefContext, resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { PDFSearchParams, getPDFSearchParams } from '@/lib/urls';
import { getContentTitle } from '@/lib/utils';

import './pdf.css';
import { PageControlButtons } from './PageControlButtons';
@@ -47,7 +48,7 @@ export async function generateMetadata(): Promise<Metadata> {
]);

return {
title: customization.title ?? space.title,
title: getContentTitle(space, customization, null),
robots: 'noindex, nofollow',
};
}
2 changes: 1 addition & 1 deletion packages/gitbook/src/lib/seo.ts
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ export function isPageIndexable(
/**
* Return true if a space should be indexed by search engines.
*/
export async function isSpaceIndexable({ space, site }: { space: Space; site: Site | null }) {
export async function isSpaceIndexable(site: Site | null) {
const headersList = await headers();

if (
Loading
Oops, something went wrong.