File tree 5 files changed +37
-17
lines changed
5 files changed +37
-17
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
+ ] ,
18
+ } )
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ In Nuxt Content v3 we need to use the `asSitemapCollection()`{lang="ts"} functio
13
13
to be able to use the ` sitemap ` frontmatter key.
14
14
15
15
``` ts [content.config.ts]
16
- import { defineCollection , defineContentConfig , z } from ' @nuxt/content'
17
- import { asSitemapCollection } from ' @nuxtjs/sitemap'
16
+ import { defineCollection , defineContentConfig } from ' @nuxt/content'
17
+ import { asSitemapCollection } from ' @nuxtjs/sitemap/content '
18
18
19
19
export default defineContentConfig ({
20
20
collections: {
Original file line number Diff line number Diff line change 27
27
"types" : " ./dist/types.d.ts" ,
28
28
"import" : " ./dist/module.mjs" ,
29
29
"require" : " ./dist/module.cjs"
30
+ },
31
+ "./content" : {
32
+ "types" : " ./dist/content.d.ts" ,
33
+ "import" : " ./dist/content.mjs" ,
34
+ "require" : " ./dist/content.cjs"
30
35
}
31
36
},
32
37
"main" : " ./dist/module.cjs" ,
33
38
"types" : " ./dist/types.d.ts" ,
34
39
"files" : [
35
40
" dist" ,
36
- " virtual.d.ts"
41
+ " virtual.d.ts" ,
42
+ " content.d.ts"
37
43
],
44
+ "typesVersions" : {
45
+ "*" : {
46
+ "content" : [
47
+ " dist/content"
48
+ ]
49
+ }
50
+ },
38
51
"scripts" : {
39
52
"lint" : " eslint ." ,
40
53
"lint:type" : " tsc --noEmit" ,
83
96
"resolutions" : {
84
97
"postcss" : " 8.4.47" ,
85
98
"typescript" : " 5.6.3"
86
- },
87
- "build" : {
88
- "externals" : [
89
- " h3" ,
90
- " std-env" ,
91
- " nitropack" ,
92
- " consola" ,
93
- " @nuxt/content"
94
- ]
95
99
}
96
100
}
Original file line number Diff line number Diff line change 1
- import { z } from '@nuxt/content'
1
+ import { type DefinedCollection , z } from '@nuxt/content'
2
2
3
3
const sitemap = z . object ( {
4
4
loc : z . string ( ) . optional ( ) ,
@@ -34,9 +34,9 @@ const sitemap = z.object({
34
34
} ) ) . optional ( ) ,
35
35
} ) . optional ( )
36
36
37
- export function asSitemapCollection ( collection : any ) {
37
+ export function asSitemapCollection < T extends DefinedCollection > ( collection : T ) : T {
38
38
if ( collection . type !== 'page' ) {
39
- return
39
+ return collection
40
40
}
41
41
if ( ! collection . schema ) {
42
42
collection . schema = z . object ( {
Original file line number Diff line number Diff line change @@ -44,8 +44,6 @@ import { normalizeFilters } from './util/filter'
44
44
// eslint-disable-next-line
45
45
export interface ModuleOptions extends _ModuleOptions { }
46
46
47
- export * from './content'
48
-
49
47
export default defineNuxtModule < ModuleOptions > ( {
50
48
meta : {
51
49
name : '@nuxtjs/sitemap' ,
You can’t perform that action at this time.
0 commit comments