|
@ -17,34 +17,23 @@ export class SitemapService { |
|
|
public getPersonalFinanceTools({ currentDate }: { currentDate: string }) { |
|
|
public getPersonalFinanceTools({ currentDate }: { currentDate: string }) { |
|
|
const rootUrl = this.configurationService.get('ROOT_URL'); |
|
|
const rootUrl = this.configurationService.get('ROOT_URL'); |
|
|
|
|
|
|
|
|
return personalFinanceTools |
|
|
return SUPPORTED_LANGUAGE_CODES.flatMap((languageCode) => { |
|
|
.map(({ alias, key }) => { |
|
|
return personalFinanceTools.map(({ alias, key }) => { |
|
|
return SUPPORTED_LANGUAGE_CODES.map((languageCode) => { |
|
|
const pathSegments = [ |
|
|
const resourcesPath = this.i18nService.getTranslation({ |
|
|
'resources', |
|
|
languageCode, |
|
|
'personalFinanceTools', |
|
|
id: 'routes.resources' |
|
|
'openSourceAlternativeTo' |
|
|
}); |
|
|
]; |
|
|
|
|
|
const params = { |
|
|
const personalFinanceToolsPath = this.i18nService.getTranslation({ |
|
|
rootUrl, |
|
|
languageCode, |
|
|
languageCode, |
|
|
id: 'routes.resources.personalFinanceTools' |
|
|
currentDate, |
|
|
}); |
|
|
urlPostfix: alias ?? key |
|
|
|
|
|
}; |
|
|
const openSourceAlternativeToPath = this.i18nService.getTranslation({ |
|
|
|
|
|
languageCode, |
|
|
return this.createSitemapUrl(pathSegments, params); |
|
|
id: 'routes.resources.personalFinanceTools.openSourceAlternativeTo' |
|
|
}); |
|
|
}); |
|
|
}).join('\n'); |
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
' <url>', |
|
|
|
|
|
` <loc>${rootUrl}/${languageCode}/${resourcesPath}/${personalFinanceToolsPath}/${openSourceAlternativeToPath}-${alias ?? key}</loc>`, |
|
|
|
|
|
` <lastmod>${currentDate}T00:00:00+00:00</lastmod>`, |
|
|
|
|
|
' </url>' |
|
|
|
|
|
].join('\n'); |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
.flat() |
|
|
|
|
|
.join('\n'); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public getPublicRoutes({ currentDate }: { currentDate: string }) { |
|
|
public getPublicRoutes({ currentDate }: { currentDate: string }) { |
|
@ -59,7 +48,7 @@ export class SitemapService { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// add language specific root URL
|
|
|
// add language specific root URL
|
|
|
const urls = [this.createRouteSitemapUrl(pathSegments, params)]; |
|
|
const urls = [this.createSitemapUrl(pathSegments, params)]; |
|
|
|
|
|
|
|
|
urls.push(...this.createSitemapUrls(publicRoutes, pathSegments, params)); |
|
|
urls.push(...this.createSitemapUrls(publicRoutes, pathSegments, params)); |
|
|
|
|
|
|
|
@ -80,7 +69,7 @@ export class SitemapService { |
|
|
this.kebabToCamel(route.path) |
|
|
this.kebabToCamel(route.path) |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
const urls = [this.createRouteSitemapUrl(currentPathSegments, params)]; |
|
|
const urls = [this.createSitemapUrl(currentPathSegments, params)]; |
|
|
|
|
|
|
|
|
if (route.subRoutes) { |
|
|
if (route.subRoutes) { |
|
|
urls.push( |
|
|
urls.push( |
|
@ -96,13 +85,19 @@ export class SitemapService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private createRouteSitemapUrl( |
|
|
private createSitemapUrl( |
|
|
pathSegments: string[], |
|
|
pathSegments: string[], |
|
|
{ |
|
|
{ |
|
|
rootUrl, |
|
|
rootUrl, |
|
|
languageCode, |
|
|
languageCode, |
|
|
currentDate |
|
|
currentDate, |
|
|
}: { rootUrl: string; languageCode: string; currentDate: string } |
|
|
urlPostfix |
|
|
|
|
|
}: { |
|
|
|
|
|
rootUrl: string; |
|
|
|
|
|
languageCode: string; |
|
|
|
|
|
currentDate: string; |
|
|
|
|
|
urlPostfix?: string; |
|
|
|
|
|
} |
|
|
): string { |
|
|
): string { |
|
|
const segments = pathSegments.map((_, index, segments) => { |
|
|
const segments = pathSegments.map((_, index, segments) => { |
|
|
const translationId = ['routes', ...segments.slice(0, index + 1)].join( |
|
|
const translationId = ['routes', ...segments.slice(0, index + 1)].join( |
|
@ -114,7 +109,9 @@ export class SitemapService { |
|
|
id: translationId |
|
|
id: translationId |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
const location = [rootUrl, languageCode, ...segments].join('/'); |
|
|
const location = |
|
|
|
|
|
[rootUrl, languageCode, ...segments].join('/') + |
|
|
|
|
|
(urlPostfix ? `-${urlPostfix}` : ''); |
|
|
|
|
|
|
|
|
return [ |
|
|
return [ |
|
|
' <url>', |
|
|
' <url>', |
|
|