Browse Source

Optimize performance

pull/5309/head
Thomas Kaul 3 weeks ago
parent
commit
d290835168
  1. 50
      apps/api/src/app/endpoints/sitemap/sitemap.service.ts

50
apps/api/src/app/endpoints/sitemap/sitemap.service.ts

@ -21,18 +21,42 @@ export class SitemapService {
const rootUrl = this.configurationService.get('ROOT_URL');
return SUPPORTED_LANGUAGE_CODES.flatMap((languageCode) => {
return personalFinanceTools.map(({ alias, key }) => {
const route =
publicRoutes.resources.subRoutes.personalFinanceTools.subRoutes
.product;
const params = {
currentDate,
const resourcesPath = this.i18nService.getTranslation({
languageCode,
id: publicRoutes.resources.path.match(
SitemapService.TRANSLATION_TAGGED_MESSAGE_REGEX
).groups.id
});
const personalFinanceToolsPath = this.i18nService.getTranslation({
languageCode,
id: publicRoutes.resources.subRoutes.personalFinanceTools.path.match(
SitemapService.TRANSLATION_TAGGED_MESSAGE_REGEX
).groups.id
});
const productPath = this.i18nService.getTranslation({
languageCode,
id: publicRoutes.resources.subRoutes.personalFinanceTools.subRoutes.product.path.match(
SitemapService.TRANSLATION_TAGGED_MESSAGE_REGEX
).groups.id
});
return personalFinanceTools.map(({ alias, key }) => {
const location = [
rootUrl,
urlPostfix: alias ?? key
};
languageCode,
resourcesPath,
personalFinanceToolsPath,
`${productPath}-${alias ?? key}`
].join('/');
return this.createRouteSitemapUrl({ ...params, route });
return [
' <url>',
` <loc>${location}</loc>`,
` <lastmod>${currentDate}T00:00:00+00:00</lastmod>`,
' </url>'
].join('\n');
});
}).join('\n');
}
@ -58,14 +82,12 @@ export class SitemapService {
currentDate,
languageCode,
rootUrl,
route,
urlPostfix
route
}: {
currentDate: string;
languageCode: string;
rootUrl: string;
route?: PublicRoute;
urlPostfix?: string;
}): string {
const segments =
route?.routerLink.map((link) => {
@ -83,9 +105,7 @@ export class SitemapService {
return segment.replace(/^\/+|\/+$/, '');
}) ?? [];
const location =
[rootUrl, languageCode, ...segments].join('/') +
(urlPostfix ? `-${urlPostfix}` : '');
const location = [rootUrl, languageCode, ...segments].join('/');
return [
' <url>',

Loading…
Cancel
Save