Skip to content

Commit

Permalink
fix: disable Nuxt Content integration with v3
Browse files Browse the repository at this point in the history
Relates to #393
  • Loading branch information
harlan-zw committed Jan 14, 2025
1 parent ec6ce0d commit 9d8f01b
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,28 +352,33 @@ declare module 'vue-router' {
// @ts-expect-error untyped
const isNuxtContentDocumentDriven = (!!nuxt.options.content?.documentDriven || config.strictNuxtContentPaths)
if (hasNuxtModule('@nuxt/content')) {
addServerPlugin(resolve('./runtime/server/plugins/nuxt-content'))
addServerHandler({
route: '/__sitemap__/nuxt-content-urls.json',
handler: resolve('./runtime/server/routes/__sitemap__/nuxt-content-urls'),
})
const tips: string[] = []
// @ts-expect-error untyped
if (nuxt.options.content?.documentDriven)
tips.push('Enabled because you\'re using `@nuxt/content` with `documentDriven: true`.')
else if (config.strictNuxtContentPaths)
tips.push('Enabled because you\'ve set `config.strictNuxtContentPaths: true`.')
else
tips.push('You can provide a `sitemap` key in your markdown frontmatter to configure specific URLs. Make sure you include a `loc`.')

appGlobalSources.push({
context: {
name: '@nuxt/content:urls',
description: 'Generated from your markdown files.',
tips,
},
fetch: '/__sitemap__/nuxt-content-urls.json',
})
if (await hasNuxtModuleCompatibility('@nuxt/content', '^3')) {
logger.warn('Nuxt Sitemap does not work with Nuxt Content v3 yet, the integration will be disabled.')
}
else {
addServerPlugin(resolve('./runtime/server/plugins/nuxt-content'))
addServerHandler({
route: '/__sitemap__/nuxt-content-urls.json',
handler: resolve('./runtime/server/routes/__sitemap__/nuxt-content-urls'),
})
const tips: string[] = []
// @ts-expect-error untyped
if (nuxt.options.content?.documentDriven)
tips.push('Enabled because you\'re using `@nuxt/content` with `documentDriven: true`.')
else if (config.strictNuxtContentPaths)
tips.push('Enabled because you\'ve set `config.strictNuxtContentPaths: true`.')
else
tips.push('You can provide a `sitemap` key in your markdown frontmatter to configure specific URLs. Make sure you include a `loc`.')

appGlobalSources.push({
context: {
name: '@nuxt/content:urls',
description: 'Generated from your markdown files.',
tips,
},
fetch: '/__sitemap__/nuxt-content-urls.json',
})
}
}

// config -> sitemaps
Expand Down

0 comments on commit 9d8f01b

Please sign in to comment.