Skip to content

Commit eb8c8c2

Browse files
authoredNov 24, 2024··
fix!: remove deprecations (#386)
1 parent 987729e commit eb8c8c2

16 files changed

+20
-131
lines changed
 

‎playground/nuxt.config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default defineNuxtConfig({
5858
prerender: true,
5959
},
6060
'/secret': {
61-
index: false,
61+
robots: false,
6262
},
6363
'/users-test/*': {
6464
sitemap: {
@@ -124,7 +124,6 @@ export default defineNuxtConfig({
124124
sitemap: {
125125
debug: true,
126126
// sitemapName: 'test.xml',
127-
// dynamicUrlsApiEndpoint: '/__sitemap',
128127
minify: false,
129128
cacheMaxAgeSeconds: 10,
130129
xslColumns: [

‎src/module.ts

+1-44
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
addServerPlugin,
66
createResolver,
77
defineNuxtModule,
8-
findPath,
98
getNuxtModuleVersion,
109
hasNuxtModule,
1110
hasNuxtModuleCompatibility,
@@ -61,7 +60,6 @@ export default defineNuxtModule<ModuleOptions>({
6160
autoLastmod: false,
6261
discoverImages: true,
6362
discoverVideos: true,
64-
dynamicUrlsApiEndpoint: '/api/_sitemap-urls',
6563
urls: [],
6664
sortEntries: true,
6765
sitemapsPathPrefix: '/__sitemap__/',
@@ -78,7 +76,6 @@ export default defineNuxtModule<ModuleOptions>({
7876
// sources
7977
sources: [],
8078
excludeAppSources: [],
81-
inferStaticPagesAsRoutes: true,
8279
},
8380
async setup(config, nuxt) {
8481
const { resolve } = createResolver(import.meta.url)
@@ -378,30 +375,6 @@ declare module 'vue-router' {
378375
fetch: '/__sitemap__/nuxt-content-urls.json',
379376
})
380377
}
381-
const hasLegacyDefaultApiSource = !!(await findPath(resolve(nuxt.options.serverDir, 'api/_sitemap-urls')))
382-
if (
383-
// make sure they didn't manually add it as a source
384-
!config.sources?.includes('/api/_sitemap-urls')
385-
// if they didn't and they have the file OR if they've manually configured the URL to something else, provide the source
386-
&& (hasLegacyDefaultApiSource || config.dynamicUrlsApiEndpoint !== '/api/_sitemap-urls')
387-
) {
388-
userGlobalSources.push({
389-
context: {
390-
name: 'dynamicUrlsApiEndpoint',
391-
description: 'Generated from your dynamicUrlsApiEndpoint config.',
392-
tips: [
393-
'The `dynamicUrlsApiEndpoint` config is deprecated.',
394-
hasLegacyDefaultApiSource
395-
? 'Consider renaming the `api/_sitemap-urls` file and add it the `sitemap.sources` config instead. This provides more explicit sitemap generation.'
396-
: 'Consider switching to using the `sitemap.sources` config which also supports fetch options.',
397-
],
398-
},
399-
fetch: hasLegacyDefaultApiSource ? '/api/_sitemap-urls' : config.dynamicUrlsApiEndpoint as string,
400-
})
401-
}
402-
else {
403-
config.dynamicUrlsApiEndpoint = false
404-
}
405378

406379
// config -> sitemaps
407380
const sitemaps: ModuleRuntimeConfig['sitemaps'] = {}
@@ -434,7 +407,7 @@ declare module 'vue-router' {
434407
{
435408
sitemapName,
436409
_route: withBase(joinURL(config.sitemapsPathPrefix, `${sitemapName}.xml`), nuxt.options.app.baseURL || '/'),
437-
_hasSourceChunk: typeof definition.urls !== 'undefined' || definition.sources?.length || !!definition.dynamicUrlsApiEndpoint,
410+
_hasSourceChunk: typeof definition.urls !== 'undefined' || definition.sources?.length,
438411
},
439412
{ ...definition, urls: undefined, sources: undefined },
440413
{ include: config.include, exclude: config.exclude },
@@ -561,10 +534,6 @@ declare module 'vue-router' {
561534
setupDevToolsUI(config, resolve)
562535
}
563536

564-
// support deprecated config
565-
if (!config.inferStaticPagesAsRoutes)
566-
config.excludeAppSources = true
567-
568537
const imports: typeof nuxt.options.imports.imports = [
569538
{
570539
from: resolve('./runtime/server/composables/defineSitemapEventHandler'),
@@ -700,18 +669,6 @@ declare module 'vue-router' {
700669
urls: await resolveUrls(definition.urls, { path: `sitemaps:${sitemapName}:urls`, logger }),
701670
})
702671
}
703-
if (definition!.dynamicUrlsApiEndpoint) {
704-
sitemapSources[sitemapName].push({
705-
context: {
706-
name: `${sitemapName}:dynamicUrlsApiEndpoint`,
707-
description: `Generated from your ${sitemapName}:dynamicUrlsApiEndpoint config.`,
708-
tips: [
709-
`You should switch to using the \`sitemaps.${sitemapName}.sources\` config which also supports fetch options.`,
710-
],
711-
},
712-
fetch: definition!.dynamicUrlsApiEndpoint,
713-
})
714-
}
715672
sitemapSources[sitemapName].push(...(definition.sources || [])
716673
.map((s) => {
717674
if (typeof s === 'string' || Array.isArray(s)) {

‎src/runtime/server/plugins/nuxt-content.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineNitroPlugin((nitroApp: NitroApp) => {
1010
// @ts-expect-error untyped
1111
nitroApp.hooks.hook('content:file:afterParse', async (content: ParsedContent) => {
1212
const validExtensions = ['md', 'mdx']
13-
if (content.sitemap === false || content._draft || !validExtensions.includes(content._extension) || content._partial || content.indexable === false || content.index === false)
13+
if (content.sitemap === false || content._draft || !validExtensions.includes(content._extension) || content._partial || content.robots === false)
1414
return
1515

1616
// add any top level images

‎src/runtime/server/sitemap/nitro.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ export async function createSitemap(event: H3Event, definition: SitemapDefinitio
7070

7171
if (routeRules.sitemap === false)
7272
return false
73-
if ((typeof routeRules.index !== 'undefined' && !routeRules.index)
74-
// @ts-expect-error runtime types
75-
|| (typeof routeRules.robots !== 'undefined' && !routeRules.robots)
76-
) {
73+
// @ts-expect-error runtime types
74+
if (typeof routeRules.robots !== 'undefined' && !routeRules.robots) {
7775
return false
7876
}
7977
const hasRobotsDisabled = Object.entries(routeRules.headers || {})

‎src/runtime/types.ts

-25
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ export interface ModuleOptions extends SitemapDefinition {
3434
* @default false
3535
*/
3636
autoLastmod: boolean
37-
/**
38-
* Should pages be automatically added to the sitemap.
39-
*
40-
* @default true
41-
* @deprecated If set to false, use `excludeAppSources: ['pages', 'route-rules', 'prerender']` instead. Otherwise, remove this.
42-
*/
43-
inferStaticPagesAsRoutes: boolean
4437
/**
4538
* Sources to exclude from the sitemap.
4639
*/
@@ -134,14 +127,6 @@ export interface ModuleOptions extends SitemapDefinition {
134127
* @default true
135128
*/
136129
credits: boolean
137-
/**
138-
* How long, in milliseconds, should the sitemap be cached for.
139-
*
140-
* @default 1 hour
141-
*
142-
* @deprecated use cacheMaxAgeSeconds
143-
*/
144-
cacheTtl?: number | false
145130
/**
146131
* How long, in seconds, should the sitemap be cached for.
147132
*
@@ -312,12 +297,6 @@ export interface SitemapDefinition {
312297
* Additional sources of URLs to include in the sitemap.
313298
*/
314299
sources?: SitemapSourceInput[]
315-
/**
316-
* The endpoint to fetch dynamic URLs from.
317-
*
318-
* @deprecated use `sources`
319-
*/
320-
dynamicUrlsApiEndpoint?: string | false
321300
/**
322301
* @internal
323302
*/
@@ -358,10 +337,6 @@ export interface SitemapUrl {
358337
videos?: Array<VideoEntry>
359338
_i18nTransform?: boolean
360339
_sitemap?: string
361-
/**
362-
* @deprecated use `loc`
363-
*/
364-
url?: string
365340
}
366341

367342
export interface AlternativeEntry {

‎src/util/nuxtSitemap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export function generateExtraRoutesFromNuxtConfig(nuxt: Nuxt = useNuxt()) {
221221
// make sure key doesn't use a wildcard and its not for a file
222222
if (k.includes('*') || k.includes('.') || k.includes(':'))
223223
return false
224-
if (typeof v.index === 'boolean' && !v.index)
224+
if (typeof v.robots === 'boolean' && !v.robots)
225225
return false
226226
// make sure that we're not redirecting
227227
return !v.redirect

‎test/fixtures/i18n-micro/nuxt.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default defineNuxtConfig({
3838
meta: true,
3939
},
4040
sitemap: {
41-
dynamicUrlsApiEndpoint: '/__sitemap',
41+
sources: ['/__sitemap'],
4242
autoLastmod: false,
4343
credits: false,
4444
debug: true,

‎test/fixtures/i18n/nuxt.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default defineNuxtConfig({
3838
],
3939
},
4040
sitemap: {
41-
dynamicUrlsApiEndpoint: '/__sitemap',
41+
sources: ['/__sitemap'],
4242
autoLastmod: false,
4343
credits: false,
4444
debug: true,

‎test/fixtures/no-pages/nuxt.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default defineNuxtConfig({
99
url: 'https://nuxtseo.com',
1010
},
1111
sitemap: {
12-
dynamicUrlsApiEndpoint: '/__sitemap',
12+
sources: ['/__sitemap'],
1313
autoLastmod: false,
1414
credits: false,
1515
debug: true,

‎test/integration/i18n/route-rules.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ await setup({
3232
},
3333
routeRules: {
3434
'/hidden': {
35-
index: false,
35+
robots: false,
3636
},
3737
'/defaults': {
3838
sitemap: {
@@ -47,7 +47,7 @@ await setup({
4747
},
4848
},
4949
'/wildcard/hidden/**': {
50-
index: false,
50+
robots: false,
5151
},
5252
},
5353
},

‎test/integration/multi/endpoints.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ await setup({
1010
sitemap: {
1111
sitemaps: {
1212
foo: {
13-
dynamicUrlsApiEndpoint: '/api/sitemap/foo',
13+
sources: ['/api/sitemap/foo'],
1414
defaults: {
1515
changefreq: 'weekly',
1616
priority: 0.7,
1717
},
1818
},
1919
bar: {
20-
dynamicUrlsApiEndpoint: '/api/sitemap/bar',
20+
sources: ['/api/sitemap/bar'],
2121
},
2222
},
2323
},

‎test/integration/single/changeApiUrl.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ await setup({
88
rootDir: resolve('../../fixtures/basic'),
99
nuxtConfig: {
1010
sitemap: {
11-
dynamicUrlsApiEndpoint: '/__sitemap',
11+
sources: ['/__sitemap'],
1212
},
1313
},
1414
})

‎test/integration/single/inferStaticPagesAsRoutes.test.ts

-40
This file was deleted.

‎test/integration/single/routeRules.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ await setup({
2222
redirect: '/defaults',
2323
},
2424
'/hidden': {
25-
index: false,
25+
robots: false,
2626
},
2727
'/defaults': {
2828
sitemap: {
@@ -37,7 +37,7 @@ await setup({
3737
},
3838
},
3939
'/wildcard/hidden/**': {
40-
index: false,
40+
robots: false,
4141
},
4242
},
4343
},

‎test/integration/single/routeRulesTrailingSlash.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ await setup({
1616
},
1717
routeRules: {
1818
'/hidden': {
19-
index: false,
19+
robots: false,
2020
},
2121
'/hidden/': {
22-
index: false,
22+
robots: false,
2323
},
2424
'/defaults': {
2525
sitemap: {
@@ -34,7 +34,7 @@ await setup({
3434
},
3535
},
3636
'/wildcard/hidden/**': {
37-
index: false,
37+
robots: false,
3838
},
3939
},
4040
},

‎test/integration/single/trailingSlashes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ await setup({
1313
},
1414
sitemap: {
1515
// test from endpoint as well
16-
dynamicUrlsApiEndpoint: '/__sitemap',
16+
sources: ['/__sitemap'],
1717
},
1818
},
1919
})

0 commit comments

Comments
 (0)
Please sign in to comment.