From 4e99d12be16185adf5f647206247ce575f43ab82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20K=C3=BCng?= Date: Mon, 23 Mar 2026 16:14:04 +0100 Subject: [PATCH 1/2] fix(front-end): seo improvemnts --- .../features/shop/product-detail.component.ts | 17 +++++++++++---- .../app/features/shop/shop-page.component.ts | 21 ++++++++++++++----- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/features/shop/product-detail.component.ts b/frontend/src/app/features/shop/product-detail.component.ts index aa84d05..df01226 100644 --- a/frontend/src/app/features/shop/product-detail.component.ts +++ b/frontend/src/app/features/shop/product-detail.component.ts @@ -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(); } - 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 { diff --git a/frontend/src/app/features/shop/shop-page.component.ts b/frontend/src/app/features/shop/shop-page.component.ts index 404611c..9bfb6e5 100644 --- a/frontend/src/app/features/shop/shop-page.component.ts +++ b/frontend/src/app/features/shop/shop-page.component.ts @@ -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(); } - 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; -- 2.49.1 From 02aac24a095a263cf8da6f0feb588884992b0dda Mon Sep 17 00:00:00 2001 From: printcalc-ci Date: Mon, 23 Mar 2026 15:15:15 +0000 Subject: [PATCH 2/2] style: apply prettier formatting --- frontend/src/app/features/shop/product-detail.component.ts | 4 +--- frontend/src/app/features/shop/shop-page.component.ts | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/features/shop/product-detail.component.ts b/frontend/src/app/features/shop/product-detail.component.ts index df01226..56e01b0 100644 --- a/frontend/src/app/features/shop/product-detail.component.ts +++ b/frontend/src/app/features/shop/product-detail.component.ts @@ -237,9 +237,7 @@ export class ProductDetailComponent { this.setSelectedImageAssetId(null); this.modelFile.set(null); const isNotFound = error?.status === 404; - this.error.set( - isNotFound ? 'SHOP.NOT_FOUND' : 'SHOP.LOAD_ERROR', - ); + this.error.set(isNotFound ? 'SHOP.NOT_FOUND' : 'SHOP.LOAD_ERROR'); this.setResponseStatus(isNotFound ? 404 : 503); if (this.shouldApplyFallbackSeo(error)) { this.applyFallbackSeo(); diff --git a/frontend/src/app/features/shop/shop-page.component.ts b/frontend/src/app/features/shop/shop-page.component.ts index 9bfb6e5..b0ce242 100644 --- a/frontend/src/app/features/shop/shop-page.component.ts +++ b/frontend/src/app/features/shop/shop-page.component.ts @@ -120,9 +120,7 @@ export class ShopPageComponent { this.categoryNodes.set([]); this.selectedCategory.set(null); this.products.set([]); - this.error.set( - isNotFound ? 'SHOP.NOT_FOUND' : 'SHOP.LOAD_ERROR', - ); + this.error.set(isNotFound ? 'SHOP.NOT_FOUND' : 'SHOP.LOAD_ERROR'); this.setResponseStatus(isNotFound ? 404 : 503); if (this.shouldApplyErrorSeo(error)) { this.applyErrorSeo(); -- 2.49.1