Skip to content

Commit

Permalink
fix(module): prevent false positive warning about ignored root keys (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
madebyfabian authored Aug 12, 2024
1 parent aab73af commit e45432b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,18 @@ export default defineNuxtModule<ModuleOptions>({
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')
}
const warnForIgnoredKey = (key: string) => {
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')
}

switch (true) {
case config?.sources?.length !== 0:
warnForIgnoredKey('sources')
break
case config?.includeAppSources !== undefined:
warnForIgnoredKey('includeAppSources')
break
}
}
}
Expand Down

0 comments on commit e45432b

Please sign in to comment.