@@ -7,7 +7,7 @@ import { matchPathToRule, normaliseRobotsRouteRule } from '../../util'
7
7
import { useRuntimeConfig } from '#imports'
8
8
import { getSiteRobotConfig } from '#internal/nuxt-robots'
9
9
10
- export function getPathRobotConfig ( e : H3Event , options ?: { userAgent ?: string , skipSiteIndexable ?: boolean , path ?: string } ) : { rule : string , indexable : boolean , debug ?: { source : string , line : string } } {
10
+ export function getPathRobotConfig ( e : H3Event , options ?: { userAgent ?: string , skipSiteIndexable ?: boolean , path ?: string } ) : { rule : string , indexable : boolean , debug ?: { source : string , line : string } } {
11
11
// has already been resolved
12
12
const { robotsDisabledValue, robotsEnabledValue, usingNuxtContent } = useRuntimeConfig ( ) [ 'nuxt-robots' ]
13
13
if ( ! options ?. skipSiteIndexable ) {
@@ -34,6 +34,16 @@ export function getPathRobotConfig(e: H3Event, options?: { userAgent?: string, s
34
34
...nitroApp . _robots . ctx . groups . filter ( g => g . userAgent . includes ( '*' ) ) ,
35
35
]
36
36
for ( const group of groups ) {
37
+ if ( ! group . _indexable ) {
38
+ return {
39
+ indexable : false ,
40
+ rule : robotsDisabledValue ,
41
+ debug : {
42
+ source : '/robots.txt' ,
43
+ line : `Disallow: /` ,
44
+ } ,
45
+ }
46
+ }
37
47
const robotsTxtRule = matchPathToRule ( path , group . _rules )
38
48
if ( robotsTxtRule ) {
39
49
if ( ! robotsTxtRule . allow ) {
@@ -65,7 +75,7 @@ export function getPathRobotConfig(e: H3Event, options?: { userAgent?: string, s
65
75
// 3. nitro route rules
66
76
nitroApp . _robotsRuleMactcher = nitroApp . _robotsRuleMactcher || createNitroRouteRuleMatcher ( )
67
77
const routeRules = normaliseRobotsRouteRule ( nitroApp . _robotsRuleMactcher ( path ) )
68
- if ( routeRules ) {
78
+ if ( routeRules && ( routeRules . allow || routeRules . rule ) ) {
69
79
return {
70
80
indexable : routeRules . allow ,
71
81
rule : routeRules . rule || ( routeRules . allow ? robotsEnabledValue : robotsDisabledValue ) ,
0 commit comments