diff --git a/src/runtime/sitemap/builder/sitemap-index.ts b/src/runtime/sitemap/builder/sitemap-index.ts index 2e15d62c..f9e7978f 100644 --- a/src/runtime/sitemap/builder/sitemap-index.ts +++ b/src/runtime/sitemap/builder/sitemap-index.ts @@ -55,7 +55,7 @@ export async function buildSitemapIndex(resolvers: NitroUrlResolvers) { enhancedUrls = applyI18nEnhancements(enhancedUrls, { isI18nMapped, autoI18n, sitemapName: sitemap.sitemapName }) // 3. filtered urls // TODO make sure include and exclude start with baseURL? - const filteredUrls = filterSitemapUrls(enhancedUrls, sitemap) + const filteredUrls = filterSitemapUrls(enhancedUrls, { ...sitemap, autoI18n, isMultiSitemap: true }) // 4. sort const sortedUrls = maybeSort(filteredUrls) // split into the max size which should be 1000 diff --git a/src/runtime/sitemap/builder/sitemap.ts b/src/runtime/sitemap/builder/sitemap.ts index f97d4ca4..ddd80d29 100644 --- a/src/runtime/sitemap/builder/sitemap.ts +++ b/src/runtime/sitemap/builder/sitemap.ts @@ -34,6 +34,7 @@ export async function buildSitemap(sitemap: SitemapDefinition, resolvers: NitroU autoLastmod, autoI18n, isI18nMapped, + isMultiSitemap, // sorting sortEntries, // chunking @@ -117,7 +118,7 @@ export async function buildSitemap(sitemap: SitemapDefinition, resolvers: NitroU enhancedUrls = applyI18nEnhancements(enhancedUrls, { isI18nMapped, autoI18n, sitemapName: sitemap.sitemapName }) // 3. filtered urls // TODO make sure include and exclude start with baseURL? - const filteredUrls = filterSitemapUrls(enhancedUrls, { autoI18n, ...sitemap }) + const filteredUrls = filterSitemapUrls(enhancedUrls, { isMultiSitemap, autoI18n, ...sitemap }) // 4. sort const sortedUrls = maybeSort(filteredUrls) // 5. maybe slice for chunked diff --git a/src/runtime/sitemap/urlset/filter.ts b/src/runtime/sitemap/urlset/filter.ts index 87493898..cc9619eb 100644 --- a/src/runtime/sitemap/urlset/filter.ts +++ b/src/runtime/sitemap/urlset/filter.ts @@ -40,11 +40,11 @@ function createFilter(options: CreateFilterOptions = {}): (path: string) => bool } } -export function filterSitemapUrls(_urls: ResolvedSitemapUrl[], options: Pick & Pick) { +export function filterSitemapUrls(_urls: ResolvedSitemapUrl[], options: Pick & Pick) { // base may be wrong here const urlFilter = createFilter(options) return _urls.filter((e) => { - if (e._sitemap && options.sitemapName) + if (options.isMultiSitemap && e._sitemap && options.sitemapName) return e._sitemap === options.sitemapName try { const path = parseURL(e.loc).pathname