Skip to content

Commit

Permalink
fix(content): export v3 util from @nuxtjs/sitemap/content
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Jan 20, 2025
1 parent 6828a4f commit bd749e3
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
18 changes: 18 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
declaration: true,
rollup: {
emitCJS: true,
},
entries: [
{ input: 'src/content', name: 'content' },
],
externals: [
'h3',
'std-env',
'nitropack',
'consola',
'@nuxt/content',
],
})
4 changes: 2 additions & 2 deletions docs/content/2.guides/5.content.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ In Nuxt Content v3 we need to use the `asSitemapCollection()`{lang="ts"} functio
to be able to use the `sitemap` frontmatter key.

```ts [content.config.ts]
import { defineCollection, defineContentConfig, z } from '@nuxt/content'
import { asSitemapCollection } from '@nuxtjs/sitemap'
import { defineCollection, defineContentConfig } from '@nuxt/content'
import { asSitemapCollection } from '@nuxtjs/sitemap/content'

export default defineContentConfig({
collections: {
Expand Down
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,27 @@
"types": "./dist/types.d.ts",
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
},
"./content": {
"types": "./dist/content.d.ts",
"import": "./dist/content.mjs",
"require": "./dist/content.cjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/types.d.ts",
"files": [
"dist",
"virtual.d.ts"
"virtual.d.ts",
"content.d.ts"
],
"typesVersions": {
"*": {
"content": [
"dist/content"
]
}
},
"scripts": {
"lint": "eslint .",
"lint:type": "tsc --noEmit",
Expand Down Expand Up @@ -83,14 +96,5 @@
"resolutions": {
"postcss": "8.4.47",
"typescript": "5.6.3"
},
"build": {
"externals": [
"h3",
"std-env",
"nitropack",
"consola",
"@nuxt/content"
]
}
}
6 changes: 3 additions & 3 deletions src/content.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from '@nuxt/content'
import { type DefinedCollection, z } from '@nuxt/content'

const sitemap = z.object({
loc: z.string().optional(),
Expand Down Expand Up @@ -34,9 +34,9 @@ const sitemap = z.object({
})).optional(),
}).optional()

export function asSitemapCollection(collection: any) {
export function asSitemapCollection<T extends DefinedCollection>(collection: T): T {
if (collection.type !== 'page') {
return
return collection
}
if (!collection.schema) {
collection.schema = z.object({
Expand Down
2 changes: 0 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ import { normalizeFilters } from './util/filter'
// eslint-disable-next-line
export interface ModuleOptions extends _ModuleOptions {}

export * from './content'

export default defineNuxtModule<ModuleOptions>({
meta: {
name: '@nuxtjs/sitemap',
Expand Down

0 comments on commit bd749e3

Please sign in to comment.