mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-02 10:13:46 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4bd2aa1dfd |
@@ -169,8 +169,7 @@ export async function generateMetadata({
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
robots:
|
robots:
|
||||||
(await isSpaceIndexable({ space, site: site ?? null })) &&
|
(await isSpaceIndexable(site ?? null)) && isPageIndexable(ancestors, page)
|
||||||
isPageIndexable(ancestors, page)
|
|
||||||
? 'index, follow'
|
? 'index, follow'
|
||||||
: 'noindex, nofollow',
|
: 'noindex, nofollow',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,12 @@ export const runtime = 'edge';
|
|||||||
*/
|
*/
|
||||||
export async function GET(req: NextRequest) {
|
export async function GET(req: NextRequest) {
|
||||||
const pointer = await getSiteContentPointer();
|
const pointer = await getSiteContentPointer();
|
||||||
const [site, space] = await Promise.all([
|
const site = await getSite(pointer.organizationId, pointer.siteId);
|
||||||
getSite(pointer.organizationId, pointer.siteId),
|
|
||||||
getSpace(pointer.spaceId, pointer.siteShareKey),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const lines = [
|
const lines = [
|
||||||
`User-agent: *`,
|
`User-agent: *`,
|
||||||
'Disallow: /~gitbook/',
|
'Disallow: /~gitbook/',
|
||||||
...((await isSpaceIndexable({ space, site }))
|
...((await isSpaceIndexable(site))
|
||||||
? [`Allow: /`, `Sitemap: ${await getAbsoluteHref(`/sitemap.xml`, true)}`]
|
? [`Allow: /`, `Sitemap: ${await getAbsoluteHref(`/sitemap.xml`, true)}`]
|
||||||
: [`Disallow: /`]),
|
: [`Disallow: /`]),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { resolvePageId } from '@/lib/pages';
|
|||||||
import { ContentRefContext, resolveContentRef } from '@/lib/references';
|
import { ContentRefContext, resolveContentRef } from '@/lib/references';
|
||||||
import { tcls } from '@/lib/tailwind';
|
import { tcls } from '@/lib/tailwind';
|
||||||
import { PDFSearchParams, getPDFSearchParams } from '@/lib/urls';
|
import { PDFSearchParams, getPDFSearchParams } from '@/lib/urls';
|
||||||
|
import { getContentTitle } from '@/lib/utils';
|
||||||
|
|
||||||
import './pdf.css';
|
import './pdf.css';
|
||||||
import { PageControlButtons } from './PageControlButtons';
|
import { PageControlButtons } from './PageControlButtons';
|
||||||
@@ -47,7 +48,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: customization.title ?? space.title,
|
title: getContentTitle(space, customization, null),
|
||||||
robots: 'noindex, nofollow',
|
robots: 'noindex, nofollow',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export function isPageIndexable(
|
|||||||
/**
|
/**
|
||||||
* Return true if a space should be indexed by search engines.
|
* 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();
|
const headersList = await headers();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user