convert soft 404s to hard 404s in unfurler ssr

This commit is contained in:
Mononaut
2023-03-09 02:34:21 -06:00
parent 2f3e498906
commit 105cccf9b0
19 changed files with 90 additions and 9 deletions

View File

@@ -1,5 +1,7 @@
import { Injectable } from '@angular/core';
import { Title, Meta } from '@angular/platform-browser';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { filter, map, switchMap } from 'rxjs';
import { StateService } from './state.service';
@Injectable({
@@ -13,8 +15,22 @@ export class SeoService {
private titleService: Title,
private metaService: Meta,
private stateService: StateService,
private router: Router,
private activatedRoute: ActivatedRoute,
) {
this.stateService.networkChanged$.subscribe((network) => this.network = network);
this.router.events.pipe(
filter(event => event instanceof NavigationEnd),
map(() => this.activatedRoute),
map(route => {
while (route.firstChild) route = route.firstChild;
return route;
}),
filter(route => route.outlet === 'primary'),
switchMap(route => route.data),
).subscribe((data) => {
this.clearSoft404();
});
}
setTitle(newTitle: string): void {
@@ -53,4 +69,14 @@ export class SeoService {
ucfirst(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
clearSoft404() {
window['soft404'] = false;
console.log('cleared soft 404');
}
logSoft404() {
window['soft404'] = true;
console.log('set soft 404');
}
}