File tree 8 files changed +55
-28
lines changed
8 files changed +55
-28
lines changed Original file line number Diff line number Diff line change
1
+ import { defineBuildConfig } from 'unbuild'
2
+
3
+ export default defineBuildConfig ( {
4
+ declaration : true ,
5
+ rollup : {
6
+ emitCJS : true ,
7
+ } ,
8
+ entries : [
9
+ { input : 'src/content' , name : 'content' } ,
10
+ ] ,
11
+ externals : [
12
+ 'h3' ,
13
+ 'std-env' ,
14
+ 'nitropack' ,
15
+ 'consola' ,
16
+ '@nuxt/content' ,
17
+ 'zod'
18
+ ] ,
19
+ } )
Original file line number Diff line number Diff line change
1
+ export * from './dist/content'
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ In Nuxt Content v3 we need to use the `asRobotsCollection()`{lang="ts"} function
13
13
to be able to use the ` robots ` frontmatter key.
14
14
15
15
``` ts [content.config.ts]
16
- import { defineCollection , defineContentConfig , z } from ' @nuxt/content'
17
- import { asRobotsCollection } from ' @nuxtjs/robots'
16
+ import { defineCollection , defineContentConfig } from ' @nuxt/content'
17
+ import { asRobotsCollection } from ' @nuxtjs/robots/content '
18
18
19
19
export default defineContentConfig ({
20
20
collections: {
@@ -39,6 +39,7 @@ const route = useRoute()
39
39
const { data: page } = await useAsyncData(`page-${route.path}`, () => {
40
40
return queryCollection('content').path(route.path).first()
41
41
})
42
+ // Ensure the SEO meta tags are rendered
42
43
useSeoMeta(page.value.seo)
43
44
</script>
44
45
```
Original file line number Diff line number Diff line change 36
36
"./dist/runtime/util" : {
37
37
"types" : " ./dist/runtime/util.d.ts" ,
38
38
"import" : " ./dist/runtime/util.js"
39
+ },
40
+ "./content" : {
41
+ "types" : " ./dist/content.d.ts" ,
42
+ "import" : " ./dist/content.mjs" ,
43
+ "require" : " ./dist/content.cjs"
39
44
}
40
45
},
41
46
"main" : " ./dist/module.cjs" ,
42
47
"types" : " ./dist/types.d.ts" ,
48
+ "typesVersions" : {
49
+ "*" : {
50
+ "content" : [
51
+ " dist/content"
52
+ ],
53
+ "utils" : [
54
+ " dist/utils"
55
+ ]
56
+ }
57
+ },
43
58
"files" : [
44
- " dist"
59
+ " content.d.ts" ,
60
+ " dist" ,
61
+ " util.d.ts"
45
62
],
46
63
"scripts" : {
47
64
"lint" : " eslint . --fix" ,
100
117
},
101
118
"resolutions" : {
102
119
"typescript" : " 5.6.3"
103
- },
104
- "build" : {
105
- "externals" : [
106
- " h3" ,
107
- " consola" ,
108
- " @nuxt/content"
109
- ]
110
120
}
111
121
}
Original file line number Diff line number Diff line change
1
+ import type { Collection } from '@nuxt/content'
2
+ import type { TypeOf , ZodRawShape } from 'zod'
1
3
import { z } from '@nuxt/content'
2
4
3
- export function asRobotsCollection ( collection : any ) {
4
- if ( collection . type !== 'page' ) {
5
- return
6
- }
7
- if ( ! collection . schema ) {
8
- collection . schema = z . object ( {
9
- robots : z . union ( [ z . string ( ) , z . boolean ( ) ] ) . optional ( ) ,
10
- } )
11
- }
12
- else {
13
- collection . schema = collection . schema . extend ( {
14
- robots : z . union ( [ z . string ( ) , z . boolean ( ) ] ) . optional ( ) ,
15
- } )
5
+ export const schema = z . object ( {
6
+ robots : z . union ( [ z . string ( ) , z . boolean ( ) ] ) . optional ( ) ,
7
+ } )
8
+
9
+ export type RobotSchema = TypeOf < typeof schema >
10
+
11
+ export function asRobotsCollection < T extends ZodRawShape > ( collection : Collection < T > ) : Collection < T > {
12
+ if ( collection . type === 'page' ) {
13
+ // @ts -expect-error untyped
14
+ collection . schema = collection . schema ? collection . schema . extend ( schema ) : schema
16
15
}
17
- collection . _integrations = collection . _integrations || [ ]
18
- collection . _integrations . push ( 'robots' )
19
16
return collection
20
17
}
Original file line number Diff line number Diff line change @@ -169,8 +169,6 @@ export interface ModulePublicRuntimeConfig {
169
169
[ 'nuxt-robots' ] : ResolvedModuleOptions
170
170
}
171
171
172
- export * from './content'
173
-
174
172
export default defineNuxtModule < ModuleOptions > ( {
175
173
meta : {
176
174
name : '@nuxtjs/robots' ,
Original file line number Diff line number Diff line change 1
1
import { defineCollection , defineContentConfig , z } from '@nuxt/content'
2
- import { asRobotsCollection } from '../../../src/module '
2
+ import { asRobotsCollection } from '../../../src/content '
3
3
4
4
export default defineContentConfig ( {
5
5
collections : {
Original file line number Diff line number Diff line change
1
+ export * from './dist/runtime/util'
You can’t perform that action at this time.
0 commit comments