Skip to content

Commit

Permalink
fix: less aggressive multi-sitemap warnings
Browse files Browse the repository at this point in the history
Fixes #308
  • Loading branch information
harlan-zw committed Jul 14, 2024
1 parent 2b79f03 commit e5eecb2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,21 @@ export default defineNuxtModule<ModuleOptions>({
}

// warn about bad config
if (!nuxt.options._prepare && Object.keys(config.sitemaps || {}).length) {
// if the user is doing multi-sitempas using the sitemaps config, we warn when root keys are used as they won't do anything
const invalidRootKeys = [
'includeAppSources',
'sources',
]
for (const key of invalidRootKeys) {
if (Object.keys(config).includes(key)) {
logger.warn(`You are using multiple-sitemaps but have provided \`sitemap.${key}\` in your Nuxt config. This will be ignored, please move it to the child sitemap config.`)
logger.warn('Learn more at: https://nuxtseo.com/sitemap/guides/multi-sitemaps')
const normalizedSitemaps = typeof config.sitemaps === 'boolean' ? {} : config.sitemaps || {}
if (!nuxt.options._prepare && Object.keys(normalizedSitemaps).length) {
// if the only key of config.sitemaps is `index` then we can skip this logic
const isSitemapIndexOnly = typeof normalizedSitemaps?.index !== 'undefined' && Object.keys(normalizedSitemaps).length === 1
if (!isSitemapIndexOnly) {
// if the user is doing multi-sitempas using the sitemaps config, we warn when root keys are used as they won't do anything
const invalidRootKeys = [
'includeAppSources',
'sources',
]
for (const key of invalidRootKeys) {
if (Object.keys(config).includes(key)) {
logger.warn(`You are using multiple-sitemaps but have provided \`sitemap.${key}\` in your Nuxt config. This will be ignored, please move it to the child sitemap config.`)
logger.warn('Learn more at: https://nuxtseo.com/sitemap/guides/multi-sitemaps')
}
}
}
}
Expand Down

0 comments on commit e5eecb2

Please sign in to comment.