Browse Source

Refactoring

pull/5035/head
Thomas Kaul 2 days ago
parent
commit
923d30601c
  1. 8
      apps/api/src/app/endpoints/sitemap/sitemap.service.ts
  2. 4
      libs/common/src/lib/routes/routes.ts

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

@ -32,7 +32,7 @@ export class SitemapService {
urlPostfix: alias ?? key urlPostfix: alias ?? key
}; };
return this.createRouteSitemapUrl({ route, ...params }); return this.createRouteSitemapUrl({ ...params, route });
}); });
}).join('\n'); }).join('\n');
} }
@ -48,7 +48,7 @@ export class SitemapService {
}; };
return [ return [
this.createRouteSitemapUrl(params), // create language specific root URL this.createRouteSitemapUrl(params),
...this.createSitemapUrls(params, publicRoutes) ...this.createSitemapUrls(params, publicRoutes)
]; ];
}).join('\n'); }).join('\n');
@ -63,7 +63,7 @@ export class SitemapService {
return []; return [];
} }
const urls = [this.createRouteSitemapUrl({ route, ...params })]; const urls = [this.createRouteSitemapUrl({ ...params, route })];
if (route.subRoutes) { if (route.subRoutes) {
urls.push(...this.createSitemapUrls(params, route.subRoutes)); urls.push(...this.createSitemapUrls(params, route.subRoutes));
@ -91,6 +91,7 @@ export class SitemapService {
const match = link.match( const match = link.match(
SitemapService.TRANSLATION_TAGGED_MESSAGE_REGEX SitemapService.TRANSLATION_TAGGED_MESSAGE_REGEX
); );
const segment = match const segment = match
? (this.i18nService.getTranslation({ ? (this.i18nService.getTranslation({
languageCode, languageCode,
@ -100,6 +101,7 @@ export class SitemapService {
return segment.replace(/^\/+|\/+$/, ''); return segment.replace(/^\/+|\/+$/, '');
}) ?? []; }) ?? [];
const location = const location =
[rootUrl, languageCode, ...segments].join('/') + [rootUrl, languageCode, ...segments].join('/') +
(urlPostfix ? `-${urlPostfix}` : ''); (urlPostfix ? `-${urlPostfix}` : '');

4
libs/common/src/lib/routes/routes.ts

@ -10,7 +10,9 @@ if (typeof window !== 'undefined') {
(global as any).$localize = ( (global as any).$localize = (
messageParts: TemplateStringsArray, messageParts: TemplateStringsArray,
...expressions: any[] ...expressions: any[]
) => String.raw({ raw: messageParts }, ...expressions); ) => {
return String.raw({ raw: messageParts }, ...expressions);
};
} }
export const internalRoutes: Record<string, InternalRoute> = { export const internalRoutes: Record<string, InternalRoute> = {

Loading…
Cancel
Save