From 5029be19c9b4489fb0e7f9916d2ea27480bca9be Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Sat, 19 Aug 2023 15:00:03 +0200 Subject: [PATCH] fix: maybe fix import bug Related #94 --- src/module.ts | 1 + src/utils.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/module.ts b/src/module.ts index 6fa26179..174c0547 100644 --- a/src/module.ts +++ b/src/module.ts @@ -313,6 +313,7 @@ export default defineNuxtModule({ autoLastmod: config.autoLastmod, defaultLocale: nuxtI18nConfig.defaultLocale || 'en', strategy: nuxtI18nConfig.strategy || 'no_prefix', + routeNameSeperator: nuxtI18nConfig.routesNameSeparator, }) : [] resolve(payload) diff --git a/src/utils.ts b/src/utils.ts index a8c0fdd1..af496612 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -15,7 +15,7 @@ export interface NuxtPagesToSitemapEntriesOptions { } export function convertNuxtPagesToSitemapEntries(pages: NuxtPage[], config: NuxtPagesToSitemapEntriesOptions) { - config.routeNameSeperator = config.routeNameSeperator || '__' + const routeNameSeperator = config.routeNameSeperator || '__' const flattenedPages = pages .map((page) => { return page.children?.length @@ -43,9 +43,9 @@ export function convertNuxtPagesToSitemapEntries(pages: NuxtPage[], config: Nuxt }) const localeGropes = {} - pagesWithMeta.reduce((acc, entry) => { - if (entry.page.name.includes(config.routeNameSeperator)) { - let [name, locale] = entry.page.name.split(config.routeNameSeperator) + pagesWithMeta.reduce((acc: Record, entry) => { + if (entry.page.name?.includes(routeNameSeperator)) { + let [name, locale] = entry.page.name.split(routeNameSeperator) if (locale) locale = locale.slice(1) if (!acc[name])