npm run serve:ssr funktioniert und Hamburger Menu bug fix

This commit is contained in:
2026-01-06 22:36:14 +01:00
parent 43027a54f7
commit 4f8fd77f7d
21 changed files with 371 additions and 111 deletions

View File

@@ -1,4 +1,5 @@
import { Injectable, inject } from '@angular/core';
import { Injectable, inject, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { Meta, Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
@@ -19,6 +20,8 @@ export class SeoService {
private meta = inject(Meta);
private title = inject(Title);
private router = inject(Router);
private platformId = inject(PLATFORM_ID);
private isBrowser = isPlatformBrowser(this.platformId);
private readonly defaultImage = 'https://biz-match.com/assets/images/bizmatch-og-image.jpg';
private readonly siteName = 'BizMatch';
@@ -109,6 +112,8 @@ export class SeoService {
* Update canonical URL
*/
private updateCanonicalUrl(url: string): void {
if (!this.isBrowser) return;
let link: HTMLLinkElement | null = document.querySelector('link[rel="canonical"]');
if (link) {
@@ -267,6 +272,8 @@ export class SeoService {
* Inject JSON-LD structured data into page
*/
injectStructuredData(schema: object): void {
if (!this.isBrowser) return;
// Remove existing schema script
const existingScript = document.querySelector('script[type="application/ld+json"]');
if (existingScript) {
@@ -284,6 +291,8 @@ export class SeoService {
* Clear all structured data
*/
clearStructuredData(): void {
if (!this.isBrowser) return;
const scripts = document.querySelectorAll('script[type="application/ld+json"]');
scripts.forEach(script => script.remove());
}
@@ -480,6 +489,8 @@ export class SeoService {
* Inject multiple structured data schemas
*/
injectMultipleSchemas(schemas: object[]): void {
if (!this.isBrowser) return;
// Remove existing schema scripts
this.clearStructuredData();
@@ -591,6 +602,8 @@ export class SeoService {
* Inject pagination link elements (rel="next" and rel="prev")
*/
injectPaginationLinks(baseUrl: string, currentPage: number, totalPages: number): void {
if (!this.isBrowser) return;
// Remove existing pagination links
document.querySelectorAll('link[rel="next"], link[rel="prev"]').forEach(link => link.remove());
@@ -615,6 +628,8 @@ export class SeoService {
* Clear pagination links
*/
clearPaginationLinks(): void {
if (!this.isBrowser) return;
document.querySelectorAll('link[rel="next"], link[rel="prev"]').forEach(link => link.remove());
}
}