Files
Portfolio/src/app/core/seo/seo-title.strategy.ts
Antonio Ledebuhr 46c86447d1 integration: add route metadata, JSON-LD and harden the public shell
Ship prerendered SEO, crawl files and palette/map a11y so every locale route is indexable, honest and keyboard-usable without inventing claims.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 18:28:22 +02:00

31 lines
1.0 KiB
TypeScript

import { inject, Injectable } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { RouterStateSnapshot, TitleStrategy } from '@angular/router';
import { SITE_CONTENT } from '../content/content.token';
import { isAppRouteData } from '../routing/app-route-data';
import { buildRouteMetadata } from './route-metadata';
import { SeoService } from './seo.service';
@Injectable()
export class SeoTitleStrategy extends TitleStrategy {
private readonly title = inject(Title);
private readonly seo = inject(SeoService);
private readonly content = inject(SITE_CONTENT);
override updateTitle(snapshot: RouterStateSnapshot): void {
let current = snapshot.root;
while (current.firstChild) {
current = current.firstChild;
}
if (!isAppRouteData(current.data)) {
return;
}
const metadata = buildRouteMetadata(current.data.routeId, current.data.locale, this.content);
this.title.setTitle(metadata.title);
this.seo.apply(current.data.routeId, current.data.locale);
}
}