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>
31 lines
1.0 KiB
TypeScript
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);
|
|
}
|
|
}
|