Skip to content

Commit 539285a

Browse files
authoredDec 17, 2024
fix!: deprecate disallowNonIndexableRoutes (#173)
1 parent 1425a89 commit 539285a

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed
 

‎docs/content/3.api/1.config.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ The value to use when the page is indexable.
8080

8181
The value to use when the page is not indexable.
8282

83-
## `disallowNonIndexableRoutes: boolean`{lang="ts"}
84-
85-
- Default: `'false'`{lang="ts"}
86-
87-
Should route rules which disallow indexing be added to the `/robots.txt` file.
88-
8983
## `mergeWithRobotsTxtPath: boolean | string`{lang="ts"}
9084

9185
- Default: `true`{lang="ts"}
@@ -167,3 +161,11 @@ export default defineNuxtConfig({
167161
}
168162
})
169163
```
164+
165+
## `disallowNonIndexableRoutes: boolean`{lang="ts"}
166+
167+
**⚠️ Deprecated**: Explicitly disallow routes in the `/robots.txt` file if you don't want them to be accessible.
168+
169+
- Default: `'false'`{lang="ts"}
170+
171+
Should route rules which disallow indexing be added to the `/robots.txt` file.

‎src/module.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ export interface ModuleOptions {
9393
*/
9494
robotsDisabledValue: string
9595
/**
96+
* @deprecated Explicitly add paths to your robots.txt with the `allow` and `disallow` options.
97+
*
9698
* Should route rules which disallow indexing be added to the `/robots.txt` file.
9799
*
98-
* @default true
100+
* @default false
99101
*/
100102
disallowNonIndexableRoutes: boolean
101103
/**
@@ -191,7 +193,7 @@ export default defineNuxtModule<ModuleOptions>({
191193
cacheControl: 'max-age=14400, must-revalidate',
192194
robotsEnabledValue: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1',
193195
robotsDisabledValue: 'noindex, nofollow',
194-
disallowNonIndexableRoutes: true,
196+
disallowNonIndexableRoutes: false,
195197
robotsTxt: true,
196198
},
197199
async setup(config, nuxt) {

‎src/runtime/server/composables/getPathRobotConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function getPathRobotConfig(e: H3Event, options?: { userAgent?: string, s
8282
// 3. nitro route rules
8383
nitroApp._robotsRuleMactcher = nitroApp._robotsRuleMactcher || createNitroRouteRuleMatcher()
8484
const routeRules = normaliseRobotsRouteRule(nitroApp._robotsRuleMactcher(path))
85-
if (routeRules && (routeRules.allow || routeRules.rule)) {
85+
if (routeRules && (typeof routeRules.allow !== 'undefined' || typeof routeRules.rule !== 'undefined')) {
8686
return {
8787
indexable: routeRules.allow,
8888
rule: routeRules.rule || (routeRules.allow ? robotsEnabledValue : robotsDisabledValue),

‎test/default.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ describe('default', () => {
2424
Disallow: /users/*/hidden
2525
Disallow: /?a=
2626
Disallow: /visible?*a=
27-
Disallow: /*/account
28-
Disallow: /sub/*
2927
3028
Sitemap: https://nuxtseo.com/sitemap.xml
3129
# END nuxt-robots"

‎test/groups.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ describe('stack', () => {
5656
Disallow: /users/*/hidden
5757
Disallow: /?a=
5858
Disallow: /visible?*a=
59-
Disallow: /*/account
60-
Disallow: /sub/*
6159
6260
Sitemap: https://nuxtseo.com/sitemap.xml
6361
# END nuxt-robots"

‎test/mergeWithRobotsTxtPath.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ describe('mergeWithRobotsTxtPath', () => {
2525
Allow: /secret/exception
2626
Disallow: /secret
2727
Disallow: /admin
28-
Disallow: /*/account
29-
Disallow: /sub/*
3028
3129
Sitemap: https://nuxtseo.com/sitemap.xml
3230
# END nuxt-robots"

0 commit comments

Comments
 (0)