Skip to content

Commit

Permalink
fix: merge sitemaps.index with i18n sitemap
Browse files Browse the repository at this point in the history
Fixes #216
  • Loading branch information
harlan-zw committed Jan 18, 2024
1 parent 997067c commit a1dc4bc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,18 @@ export default defineNuxtModule<ModuleOptions>({
strategy: nuxtI18nConfig.strategy as 'prefix' | 'prefix_except_default' | 'prefix_and_default',
}
}
let canI18nMap = nuxtI18nConfig.strategy !== 'no_prefix'
if (typeof config.sitemaps === 'object') {
const isSitemapIndexOnly = typeof config.sitemaps.index !== 'undefined' && Object.keys(config.sitemaps).length === 1
if (!isSitemapIndexOnly)
canI18nMap = false
}
// if they haven't set `sitemaps` explicitly then we can set it up automatically for them
if (typeof config.sitemaps === 'undefined' && !!resolvedAutoI18n && nuxtI18nConfig.strategy !== 'no_prefix') {
if (canI18nMap && resolvedAutoI18n) {
// @ts-expect-error untyped
config.sitemaps = { index: [] }
for (const locale of resolvedAutoI18n.locales) {
// @ts-expect-error untyped
config.sitemaps = { index: config.sitemaps?.index || [] }
for (const locale of resolvedAutoI18n.locales)
config.sitemaps[locale.iso || locale.code] = { includeAppSources: true }
}
isI18nMapped = true
usingMultiSitemaps = true
}
Expand Down

0 comments on commit a1dc4bc

Please sign in to comment.