37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
type BuildRobotsArgs = {
|
|
/** Absolute origin, e.g. 'https://example.com'. */
|
|
baseUrl: string;
|
|
/** Paths to disallow. Defaults to Payload's admin and API. */
|
|
disallow?: string[];
|
|
/** Whether to advertise the sitemap. Defaults to true. */
|
|
sitemap?: boolean;
|
|
};
|
|
/**
|
|
* Shape for Next's `app/robots.ts`.
|
|
*/
|
|
export type RobotsRules = {
|
|
host?: string;
|
|
rules: {
|
|
allow?: string;
|
|
disallow?: string[];
|
|
userAgent: string;
|
|
};
|
|
sitemap?: string;
|
|
};
|
|
/**
|
|
* Builds robots rules that allow crawling everything except the admin panel and
|
|
* API, and point crawlers at the sitemap.
|
|
*
|
|
* ```ts
|
|
* // app/robots.ts
|
|
* export default function robots() {
|
|
* return buildRobots({ baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })
|
|
* }
|
|
* ```
|
|
*
|
|
* The admin and API are disallowed by default — no reason for them in the index,
|
|
* and it keeps crawl budget on real content.
|
|
*/
|
|
export declare function buildRobots({ baseUrl, disallow, sitemap, }: BuildRobotsArgs): RobotsRules;
|
|
export {};
|