@@ -10,6 +10,7 @@ import {
10
10
createResolver ,
11
11
defineNuxtModule ,
12
12
hasNuxtModule ,
13
+ hasNuxtModuleCompatibility ,
13
14
} from '@nuxt/kit'
14
15
import { defu } from 'defu'
15
16
import { installNuxtSiteConfig , updateSiteConfig } from 'nuxt-site-config-kit'
@@ -127,6 +128,10 @@ export interface ModuleOptions {
127
128
* @default max-age=14400, must-revalidate
128
129
*/
129
130
cacheControl ?: string | false
131
+ /**
132
+ * Disabled the Frontmatter Nuxt Content integration.
133
+ */
134
+ disableNuxtContentIntegration ?: boolean
130
135
/**
131
136
* Whether the robots.txt file should be generated. Useful to disable when running your app with a base URL.
132
137
*
@@ -353,6 +358,19 @@ export default defineNuxtModule<ModuleOptions>({
353
358
}
354
359
}
355
360
361
+ const nitroPreset = resolveNitroPreset ( nuxt . options . nitro )
362
+ let usingNuxtContent = hasNuxtModule ( '@nuxt/content' ) && config . disableNuxtContentIntegration !== false
363
+ if ( usingNuxtContent ) {
364
+ if ( await hasNuxtModuleCompatibility ( '@nuxt/content' , '^3' ) ) {
365
+ logger . warn ( 'Nuxt Robots does not work with Nuxt Content v3 yet, the integration will be disabled. Learn more at: https://nuxtseo.com/docs/robots/guides/content' )
366
+ usingNuxtContent = false
367
+ }
368
+ else if ( nitroPreset . startsWith ( 'cloudflare' ) ) {
369
+ logger . warn ( 'The Nuxt Robots, Nuxt Content integration does not work with CloudFlare yet, the integration will be disabled. Learn more at: https://nuxtseo.com/docs/robots/guides/content' )
370
+ usingNuxtContent = false
371
+ }
372
+ }
373
+
356
374
nuxt . hook ( 'modules:done' , async ( ) => {
357
375
config . sitemap = asArray ( config . sitemap )
358
376
config . disallow = asArray ( config . disallow )
@@ -428,7 +446,7 @@ export default defineNuxtModule<ModuleOptions>({
428
446
429
447
nuxt . options . runtimeConfig [ 'nuxt-robots' ] = {
430
448
version : version || '' ,
431
- usingNuxtContent : hasNuxtModule ( '@nuxt/content' ) ,
449
+ usingNuxtContent,
432
450
debug : config . debug ,
433
451
credits : config . credits ,
434
452
groups : config . groups ,
@@ -449,7 +467,7 @@ declare module 'nitropack' {
449
467
interface NitroApp {
450
468
_robots: {
451
469
ctx: import('${ typesPath } ').HookRobotsConfigContext
452
- nuxtContentUrls: Set<string>
470
+ nuxtContentUrls? : Set<string>
453
471
},
454
472
_robotsRuleMactcher: (url: string) => string
455
473
}
@@ -489,7 +507,6 @@ declare module 'h3' {
489
507
`
490
508
} )
491
509
492
- const nitroPreset = resolveNitroPreset ( nuxt . options . nitro )
493
510
// only prerender for `nuxi generate`
494
511
const isFirebase = nitroPreset === 'firebase'
495
512
if ( ( isNuxtGenerate ( ) || ( isFirebase && nuxt . options . _build ) ) && config . robotsTxt ) {
@@ -531,7 +548,7 @@ declare module 'h3' {
531
548
} )
532
549
addServerPlugin ( resolve ( './runtime/nitro/plugins/initContext' ) )
533
550
534
- if ( hasNuxtModule ( '@nuxt/content' ) ) {
551
+ if ( usingNuxtContent ) {
535
552
addServerHandler ( {
536
553
route : '/__robots__/nuxt-content.json' ,
537
554
handler : resolve ( './runtime/nitro/server/__robots__/nuxt-content' ) ,
0 commit comments