|
1 | | -import type { H3Event } from 'h3' |
2 | | -import type { RobotsContext } from '../../types' |
| 1 | +import type { H3Event } from '#nuxtseo/h3' |
| 2 | +import type { RobotsContext, RobotsValue } from '../../types' |
3 | 3 | import { matchPathToRule, normaliseRobotsRouteRule } from '@nuxtjs/robots/util' |
4 | | -import { getRequestHeader } from 'h3' |
5 | | -import { useNitroApp, useRuntimeConfig } from 'nitropack/runtime' |
6 | 4 | import { createNitroRouteRuleMatcher } from 'nuxtseo-shared/server' |
7 | 5 | import { withoutTrailingSlash } from 'ufo' |
| 6 | +import { getRequestHeader } from '#nuxtseo/h3' |
| 7 | +import { useNitroApp, useRuntimeConfig } from '#nuxtseo/nitro' |
8 | 8 | import { getSiteRobotConfig } from './getSiteRobotConfig' |
9 | 9 | import { useRuntimeConfigNuxtRobots } from './useRuntimeConfigNuxtRobots' |
10 | 10 |
|
| 11 | +interface RobotsRouteRules { |
| 12 | + robots?: RobotsValue | { indexable: boolean, rule: string } |
| 13 | + ssr?: boolean |
| 14 | +} |
| 15 | + |
11 | 16 | export function getPathRobotConfig(e: H3Event, options?: { userAgent?: string, skipSiteIndexable?: boolean, path?: string }): RobotsContext { |
12 | 17 | const runtimeConfig = useRuntimeConfig(e) |
13 | 18 | // has already been resolved |
@@ -109,7 +114,7 @@ export function getPathRobotConfig(e: H3Event, options?: { userAgent?: string, s |
109 | 114 | } |
110 | 115 |
|
111 | 116 | // 4. nitro route rules |
112 | | - nitroApp._robotsRuleMatcher = nitroApp._robotsRuleMatcher || createNitroRouteRuleMatcher(runtimeConfig) |
| 117 | + nitroApp._robotsRuleMatcher = nitroApp._robotsRuleMatcher || createNitroRouteRuleMatcher<RobotsRouteRules>(runtimeConfig) |
113 | 118 | let robotRouteRules = nitroApp._robotsRuleMatcher(path) |
114 | 119 | let routeRulesPath = path |
115 | 120 | // if we're using i18n we need to strip leading prefixes so the rule will match |
|
0 commit comments