1
- import type { Arrayable , AutoI18nConfig , RobotsGroupInput , RobotsGroupResolved } from './runtime/types'
1
+ import type { Arrayable , AutoI18nConfig , NuxtRobotsRuntimeConfig , RobotsGroupInput , RobotsGroupResolved } from './runtime/types'
2
2
import fsp from 'node:fs/promises'
3
3
import {
4
4
addImports ,
@@ -449,7 +449,7 @@ export default defineNuxtModule<ModuleOptions>({
449
449
}
450
450
}
451
451
452
- nuxt . options . runtimeConfig [ 'nuxt-robots' ] = {
452
+ const robotsRuntimeConfig : NuxtRobotsRuntimeConfig = {
453
453
version : version || '' ,
454
454
isNuxtContentV2,
455
455
debug : config . debug ,
@@ -459,26 +459,21 @@ export default defineNuxtModule<ModuleOptions>({
459
459
header : config . header ,
460
460
robotsEnabledValue : config . robotsEnabledValue ,
461
461
robotsDisabledValue : config . robotsDisabledValue ,
462
- // @ts -expect-error untyped
463
- cacheControl : config . cacheControl ,
462
+ cacheControl : config . cacheControl ?? 'max-age=14400, must-revalidate' ,
464
463
}
464
+ nuxt . options . runtimeConfig [ 'nuxt-robots' ] = robotsRuntimeConfig as any
465
465
} )
466
466
467
467
addTypeTemplate ( {
468
468
filename : 'module/nuxt-robots.d.ts' ,
469
469
getContents : ( data ) => {
470
470
const typesPath = relative ( resolve ( data . nuxt ! . options . rootDir , data . nuxt ! . options . buildDir , 'module' ) , resolve ( 'runtime/types' ) )
471
- return `// Generated by nuxt-robots
472
-
473
- import type { RobotsContext } from '#robots/types'
474
-
475
- declare module 'nitropack/types' {
476
- interface NitroApp {
471
+ const types = ` interface NitroApp {
477
472
_robots: {
478
473
ctx: import('${ typesPath } ').HookRobotsConfigContext
479
474
nuxtContentUrls?: Set<string>
480
475
},
481
- _robotsRuleMatcher: (url: string) => string
476
+ _robotsRuleMatcher: (url: string) => any
482
477
}
483
478
interface NitroRouteRules {
484
479
robots?: boolean | string | {
@@ -495,33 +490,17 @@ declare module 'nitropack/types' {
495
490
interface NitroRuntimeHooks {
496
491
'robots:config': (ctx: import('${ typesPath } ').HookRobotsConfigContext) => void | Promise<void>
497
492
'robots:robots-txt': (ctx: import('${ typesPath } ').HookRobotsTxtContext) => void | Promise<void>
498
- }
493
+ }`
494
+ return `// Generated by nuxt-robots
495
+
496
+ import type { RobotsContext } from '#robots/types'
497
+
498
+ declare module 'nitropack/types' {
499
+ ${ types }
499
500
}
500
501
501
502
declare module 'nitropack' {
502
- interface NitroApp {
503
- _robots: {
504
- ctx: import('${ typesPath } ').HookRobotsConfigContext
505
- nuxtContentUrls?: Set<string>
506
- },
507
- _robotsRuleMatcher: (url: string) => string
508
- }
509
- interface NitroRouteRules {
510
- robots?: boolean | string | {
511
- indexable: boolean
512
- rule: string
513
- }
514
- }
515
- interface NitroRouteConfig {
516
- robots?: boolean | string | {
517
- indexable: boolean
518
- rule: string
519
- }
520
- }
521
- interface NitroRuntimeHooks {
522
- 'robots:config': (ctx: import('${ typesPath } ').HookRobotsConfigContext) => void | Promise<void>
523
- 'robots:robots-txt': (ctx: import('${ typesPath } ').HookRobotsTxtContext) => void | Promise<void>
524
- }
503
+ ${ types }
525
504
}
526
505
527
506
declare module 'h3' {
@@ -535,6 +514,7 @@ export {}
535
514
} ,
536
515
} , {
537
516
nitro : true ,
517
+ nuxt : true ,
538
518
} )
539
519
540
520
// only prerender for `nuxi generate`
0 commit comments