Skip to content

Commit bd749e3

Browse files
committedJan 20, 2025·
fix(content): export v3 util from @nuxtjs/sitemap/content
1 parent 6828a4f commit bd749e3

File tree

5 files changed

+37
-17
lines changed

5 files changed

+37
-17
lines changed
 

‎build.config.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
})

‎docs/content/2.guides/5.content.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ In Nuxt Content v3 we need to use the `asSitemapCollection()`{lang="ts"} functio
1313
to be able to use the `sitemap` frontmatter key.
1414

1515
```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'
1818

1919
export default defineContentConfig({
2020
collections: {

‎package.json

+14-10
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,27 @@
2727
"types": "./dist/types.d.ts",
2828
"import": "./dist/module.mjs",
2929
"require": "./dist/module.cjs"
30+
},
31+
"./content": {
32+
"types": "./dist/content.d.ts",
33+
"import": "./dist/content.mjs",
34+
"require": "./dist/content.cjs"
3035
}
3136
},
3237
"main": "./dist/module.cjs",
3338
"types": "./dist/types.d.ts",
3439
"files": [
3540
"dist",
36-
"virtual.d.ts"
41+
"virtual.d.ts",
42+
"content.d.ts"
3743
],
44+
"typesVersions": {
45+
"*": {
46+
"content": [
47+
"dist/content"
48+
]
49+
}
50+
},
3851
"scripts": {
3952
"lint": "eslint .",
4053
"lint:type": "tsc --noEmit",
@@ -83,14 +96,5 @@
8396
"resolutions": {
8497
"postcss": "8.4.47",
8598
"typescript": "5.6.3"
86-
},
87-
"build": {
88-
"externals": [
89-
"h3",
90-
"std-env",
91-
"nitropack",
92-
"consola",
93-
"@nuxt/content"
94-
]
9599
}
96100
}

‎src/content.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from '@nuxt/content'
1+
import { type DefinedCollection, z } from '@nuxt/content'
22

33
const sitemap = z.object({
44
loc: z.string().optional(),
@@ -34,9 +34,9 @@ const sitemap = z.object({
3434
})).optional(),
3535
}).optional()
3636

37-
export function asSitemapCollection(collection: any) {
37+
export function asSitemapCollection<T extends DefinedCollection>(collection: T): T {
3838
if (collection.type !== 'page') {
39-
return
39+
return collection
4040
}
4141
if (!collection.schema) {
4242
collection.schema = z.object({

‎src/module.ts

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ import { normalizeFilters } from './util/filter'
4444
// eslint-disable-next-line
4545
export interface ModuleOptions extends _ModuleOptions {}
4646

47-
export * from './content'
48-
4947
export default defineNuxtModule<ModuleOptions>({
5048
meta: {
5149
name: '@nuxtjs/sitemap',

0 commit comments

Comments
 (0)
Please sign in to comment.