fix(front-end): seo improvemnts
Some checks failed
Build and Deploy / build-and-push (push) Has been cancelled
Build and Deploy / deploy (push) Has been cancelled
Build and Deploy / test-backend (push) Has been cancelled
PR Checks / security-sast (pull_request) Successful in 32s
PR Checks / test-backend (pull_request) Successful in 28s
PR Checks / test-frontend (pull_request) Successful in 1m4s
PR Checks / prettier-autofix (pull_request) Failing after 12s
Build and Deploy / test-frontend (push) Has been cancelled

This commit is contained in:
2026-03-23 16:14:04 +01:00
parent d3c9dd6eb9
commit 4e99d12be1
2 changed files with 29 additions and 9 deletions

View File

@@ -236,13 +236,14 @@ export class ProductDetailComponent {
this.selectedVariantId.set(null);
this.setSelectedImageAssetId(null);
this.modelFile.set(null);
const isNotFound = error?.status === 404;
this.error.set(
error?.status === 404 ? 'SHOP.NOT_FOUND' : 'SHOP.LOAD_ERROR',
isNotFound ? 'SHOP.NOT_FOUND' : 'SHOP.LOAD_ERROR',
);
if (error?.status === 404) {
this.setResponseStatus(404);
}
this.setResponseStatus(isNotFound ? 404 : 503);
if (this.shouldApplyFallbackSeo(error)) {
this.applyFallbackSeo();
}
return of(null);
}),
finalize(() => this.loading.set(false)),
@@ -598,6 +599,14 @@ export class ProductDetailComponent {
});
}
private shouldApplyFallbackSeo(error: { status?: number } | null): boolean {
if (error?.status === 404) {
return true;
}
return !this.isBrowser;
}
private materialLabelForVariant(
variant: ShopProductVariantOption | null,
): string {

View File

@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { CommonModule, isPlatformBrowser } from '@angular/common';
import {
PLATFORM_ID,
RESPONSE_INIT,
afterNextRender,
Component,
@@ -61,6 +62,7 @@ export class ShopPageComponent {
private readonly router = inject(Router);
private readonly translate = inject(TranslateService);
private readonly seoService = inject(SeoService);
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
private readonly responseInit = inject(RESPONSE_INIT, { optional: true });
readonly languageService = inject(LanguageService);
private readonly shopRouteService = inject(ShopRouteService);
@@ -113,17 +115,18 @@ export class ShopPageComponent {
catalog: this.shopService.getProductCatalog(categorySlug ?? null),
}).pipe(
catchError((error) => {
const isNotFound = error?.status === 404;
this.categories.set([]);
this.categoryNodes.set([]);
this.selectedCategory.set(null);
this.products.set([]);
this.error.set(
error?.status === 404 ? 'SHOP.NOT_FOUND' : 'SHOP.LOAD_ERROR',
isNotFound ? 'SHOP.NOT_FOUND' : 'SHOP.LOAD_ERROR',
);
if (error?.status === 404) {
this.setResponseStatus(404);
}
this.setResponseStatus(isNotFound ? 404 : 503);
if (this.shouldApplyErrorSeo(error)) {
this.applyErrorSeo();
}
return of(null);
}),
finalize(() => this.loading.set(false)),
@@ -376,6 +379,14 @@ export class ShopPageComponent {
});
}
private shouldApplyErrorSeo(error: { status?: number } | null): boolean {
if (error?.status === 404) {
return true;
}
return !this.isBrowser;
}
private setResponseStatus(status: number): void {
if (this.responseInit) {
this.responseInit.status = status;