32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { Component, computed, inject } from '@angular/core';
|
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterOutlet } from '@angular/router';
|
|
import { filter, map } from 'rxjs';
|
|
|
|
@Component({
|
|
imports: [RouterLink, RouterOutlet],
|
|
selector: 'app-root',
|
|
styleUrl: './app.scss',
|
|
templateUrl: './app.html',
|
|
})
|
|
export class App {
|
|
private readonly router = inject(Router);
|
|
private readonly route = inject(ActivatedRoute);
|
|
|
|
private readonly leafRouteData = toSignal(
|
|
this.router.events.pipe(
|
|
filter((event) => event instanceof NavigationEnd),
|
|
map(() => {
|
|
let route = this.route;
|
|
while (route.firstChild) route = route.firstChild;
|
|
return route.snapshot.data;
|
|
}),
|
|
),
|
|
{ initialValue: {} as Record<string, unknown> },
|
|
);
|
|
|
|
/** Full-height workspace routes (`data.workspace`) drop the marketing footer. */
|
|
readonly workspace = computed(() => !!this.leafRouteData()['workspace']);
|
|
readonly breadcrumb = computed(() => this.leafRouteData()['breadcrumb'] as string | undefined);
|
|
}
|