getSiteRobotConfig()
See if the Site is indexable within Nitro.
Introduction
The
This can be useful for disabling certain SEO features when the environment does not allow for indexing.
API
function getSiteRobotConfig(e: H3Event): { indexable: boolean, hints: string[] }
Arguments
e: H3Event : The event object.
Returns
indexable: boolean : Whether the site is indexable.hints: string[] : A list of hints as to why the site is or isn't indexable.
Example
server/routes/og.png.ts
import { getSiteRobotConfig } from '#imports'
export default defineEventHandler((e) => {
const { indexable } = getSiteRobotConfig(e)
// avoid serving og images if the site is not indexable
if (!indexable) {
// ...
}
})
Did this page help you?