Skip to content

Commit a53f4cd

Browse files
committedNov 24, 2024·
fix!: drop all deprecations
1 parent 3240eec commit a53f4cd

File tree

13 files changed

+8
-131
lines changed

13 files changed

+8
-131
lines changed
 

Diff for: ‎docs/content/2.guides/2.route-rules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can provide the following rules:
1212

1313
The rules are applied using the following logic:
1414
- `X-Robots-Tag` header - SSR only,
15-
- `<meta name="robots">`{lang="html"} - When using the `defineRobotMeta` or `RobotMeta` composable or component
15+
- `<meta name="robots">`{lang="html"}
1616
- `/robots.txt` disallow entry - When [disallowNonIndexableRoutes](/docs/robots/api/config#robotsdisabledvalue) is enabled
1717

1818
## Inline Route Rules

Diff for: ‎src/module.ts

+2-70
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import type { Arrayable, AutoI18nConfig, Robots3Rules, RobotsGroupInput, RobotsGroupResolved } from './runtime/types'
1+
import type { Arrayable, AutoI18nConfig, RobotsGroupInput, RobotsGroupResolved } from './runtime/types'
22
import fsp from 'node:fs/promises'
33
import {
4-
addComponent,
54
addImports,
65
addPlugin,
76
addServerHandler,
@@ -80,10 +79,6 @@ export interface ModuleOptions {
8079
* ]
8180
*/
8281
groups: RobotsGroupInput[]
83-
/**
84-
* @deprecated backwards compatibility with Nuxt Robots v3
85-
*/
86-
rules?: Robots3Rules | Robots3Rules[]
8782
/**
8883
* The value to use when the site is indexable.
8984
*
@@ -199,10 +194,7 @@ export default defineNuxtModule<ModuleOptions>({
199194
if (config.enabled === false) {
200195
logger.debug('The module is disabled, skipping setup.')
201196
// need to mock the composables to allow module still to work when disabled
202-
;['defineRobotMeta', 'useRobotsRule']
203-
.forEach((name) => {
204-
addImports({ name, from: resolve(`./runtime/app/composables/mock`) })
205-
})
197+
addImports({ name: 'useRobotsRule', from: resolve(`./runtime/app/composables/mock`) })
206198
nuxt.options.nitro = nuxt.options.nitro || {}
207199
nuxt.options.nitro.imports = nuxt.options.nitro.imports || {}
208200
nuxt.options.nitro.imports.presets = nuxt.options.nitro.imports.presets || []
@@ -221,43 +213,6 @@ export default defineNuxtModule<ModuleOptions>({
221213
config.robotsTxt = false
222214
}
223215

224-
// TODO remove with v5
225-
if (config.rules) {
226-
// warn v3 usage and convert to v4
227-
logger.warn('The `rules` option is deprecated, please use the `groups` option instead.')
228-
if (!config.groups?.length) {
229-
const group: RobotsGroupInput = {}
230-
const keyMap: Robots3Rules = {
231-
UserAgent: 'userAgent',
232-
Disallow: 'disallow',
233-
Allow: 'allow',
234-
} as const
235-
const rules = asArray(config.rules)
236-
for (const k in rules) {
237-
// need to map all keys within the rules
238-
const rule = rules[k]
239-
for (const k2 in rule) {
240-
const key = (keyMap[k2 as keyof Robots3Rules] || k2) as (keyof RobotsGroupInput | 'Sitemap')
241-
if (key === 'Sitemap') {
242-
config.sitemap = asArray(config.sitemap)
243-
config.sitemap.push(rule[k2])
244-
}
245-
else if (keyMap[k2 as keyof Robots3Rules]) {
246-
if (group[key]) {
247-
// @ts-expect-error untyped
248-
group[key] = asArray(group[key])
249-
group[key].push(rule[k2])
250-
}
251-
else {
252-
group[key] = rule[k2]
253-
}
254-
}
255-
}
256-
}
257-
config.groups.push(group)
258-
}
259-
}
260-
261216
const resolvedAutoI18n = typeof config.autoI18n === 'boolean' ? false : (config.autoI18n || await resolveI18nConfig())
262217

263218
if (config.blockNonSeoBots) {
@@ -457,8 +412,6 @@ export default defineNuxtModule<ModuleOptions>({
457412
// @ts-expect-error untyped
458413
cacheControl: config.cacheControl,
459414
}
460-
// TODO deprecated, backwards compatiblity
461-
nuxt.options.runtimeConfig['nuxt-simple-robots'] = nuxt.options.runtimeConfig['nuxt-robots']
462415
})
463416

464417
extendTypes('nuxt-robots', ({ typesPath }) => {
@@ -472,20 +425,12 @@ declare module 'nitropack' {
472425
_robotsRuleMactcher: (url: string) => string
473426
}
474427
interface NitroRouteRules {
475-
/**
476-
* @deprecated Use \`robots: <boolean>\` instead.
477-
*/
478-
index?: boolean
479428
robots?: boolean | string | {
480429
indexable: boolean
481430
rule: string
482431
}
483432
}
484433
interface NitroRouteConfig {
485-
/**
486-
* @deprecated Use \`robots: <boolean>\` instead.
487-
*/
488-
index?: boolean
489434
robots?: boolean | string | {
490435
indexable: boolean
491436
rule: string
@@ -517,24 +462,11 @@ declare module 'h3' {
517462
logger.info('Firebase does not support dynamic robots.txt files. Prerendering /robots.txt.')
518463
}
519464

520-
// defineRobotMeta is a server-only composable
521-
nuxt.options.optimization.treeShake.composables.client['nuxt-robots'] = ['defineRobotMeta']
522-
523-
addImports({
524-
name: 'defineRobotMeta',
525-
from: resolve('./runtime/app/composables/defineRobotMeta'),
526-
})
527-
528465
addImports({
529466
name: 'useRobotsRule',
530467
from: resolve('./runtime/app/composables/useRobotsRule'),
531468
})
532469

533-
addComponent({
534-
name: 'RobotMeta',
535-
filePath: resolve('./runtime/app/components/RobotMeta'),
536-
})
537-
538470
if (config.robotsTxt) {
539471
// add robots.txt server handler
540472
addServerHandler({

Diff for: ‎src/runtime/app/components/RobotMeta.ts

-13
This file was deleted.

Diff for: ‎src/runtime/app/composables/defineRobotMeta.ts

-16
This file was deleted.

Diff for: ‎src/runtime/app/composables/mock.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type { MaybeRef } from 'vue'
22
import { ref } from 'vue'
33

4-
// eslint-disable-next-line unused-imports/no-unused-vars
5-
export function defineRobotMeta(component?: boolean) {}
6-
74
// eslint-disable-next-line unused-imports/no-unused-vars
85
export function useRobotsRule(rule?: MaybeRef<boolean | string>) {
96
return ref('')

Diff for: ‎src/runtime/server/routes/__robots__/nuxt-content.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default defineEventHandler(async (e) => {
1717
if (c._draft || c._extension !== 'md' || c._partial)
1818
return false
1919
if (c.path) {
20-
if (String(c.robots) === 'false' || String(c.indexable) === 'false' || String(c.index) === 'false')
20+
if (String(c.robots) === 'false')
2121
return c.path
2222
}
2323
return false

Diff for: ‎src/runtime/types.ts

-13
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@ export interface ParsedRobotsTxt {
1010

1111
export type RobotsGroupInput = GoogleInput | YandexInput
1212

13-
export interface Robots3Rules {
14-
UserAgent?: string
15-
BlankLine?: true
16-
Comment?: string
17-
Disallow?: string
18-
Allow?: string
19-
Host?: string
20-
Sitemap?: string
21-
// yandex only
22-
CleanParam?: string
23-
CrawlDelay?: string
24-
}
25-
2613
// google is the base input
2714
export interface GoogleInput {
2815
comment?: Arrayable<string>

Diff for: ‎src/runtime/util.ts

-2
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,6 @@ export function normaliseRobotsRouteRule(config: NitroRouteConfig) {
287287
allow = config.robots
288288
else if (typeof config.robots === 'object' && typeof config.robots.indexable !== 'undefined')
289289
allow = config.robots.indexable
290-
else if (typeof config.index !== 'undefined')
291-
allow = config.index
292290
// parse rule
293291
let rule: string | undefined
294292
if (typeof config.robots === 'object' && typeof config.robots.rule !== 'undefined')

Diff for: ‎test/fixtures/basic/pages/hidden-route-rules.vue

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
<script lang="ts" setup>
2-
import { defineRobotMeta } from '#imports'
3-
4-
defineRobotMeta()
5-
</script>
6-
71
<template>
82
<div>hello world</div>
93
</template>

Diff for: ‎test/manualNoIndexing.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ describe('manualNoIndexing', () => {
2525
it('basic', async () => {
2626
const robotsTxt = await $fetch('/robots.txt')
2727
// the site.url should be appended
28-
// site.indexable should be honoured
2928
expect(robotsTxt).toMatchInlineSnapshot(`
3029
"# START nuxt-robots (indexing disabled)
3130
User-agent: *

Diff for: ‎test/routeRules.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ await setup({
1414
},
1515
routeRules: {
1616
'/index-rule/*': {
17-
index: false,
17+
robots: false,
1818
},
1919
'/robots-rule/*': {
2020
robots: 'noindex',
@@ -28,7 +28,7 @@ await setup({
2828
robots: 'index, follow',
2929
},
3030
'/excluded/*': {
31-
index: false,
31+
robots: false,
3232
},
3333
},
3434
},

Diff for: ‎test/routeRulesTrailingSlash.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ await setup({
1212
},
1313
routeRules: {
1414
'/hidden-route-rules': {
15-
index: false,
15+
robots: false,
1616
},
1717
'/hidden-route-rules/': {
18-
index: false,
18+
robots: false,
1919
},
2020
},
2121
},

Diff for: ‎test/siteConfigLegacy.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ await setup({
2424
describe('siteConfig', () => {
2525
it('basic', async () => {
2626
const robotsTxt = await $fetch('/robots.txt')
27-
// site.indexable should be honoured
2827
expect(robotsTxt.includes('(indexable)')).toBe(true)
2928
})
3029
})

0 commit comments

Comments
 (0)
Please sign in to comment.