2024-07-23 16:50:12 +00:00
|
|
|
/*!
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
|
|
|
*/
|
|
|
|
|
|
2025-01-07 10:43:18 +00:00
|
|
|
import {ChangeDetectionStrategy, Component, inject, computed} from '@angular/core';
|
2024-07-23 16:50:12 +00:00
|
|
|
import {NavigationState} from '../../services/index';
|
|
|
|
|
import {NavigationItem} from '../../interfaces/index';
|
|
|
|
|
import {RouterLink} from '@angular/router';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'docs-breadcrumb',
|
2024-09-06 19:28:14 +00:00
|
|
|
imports: [RouterLink],
|
2024-07-23 16:50:12 +00:00
|
|
|
templateUrl: './breadcrumb.component.html',
|
|
|
|
|
styleUrls: ['./breadcrumb.component.scss'],
|
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
|
|
})
|
2025-01-07 10:43:18 +00:00
|
|
|
export class Breadcrumb {
|
2024-07-23 16:50:12 +00:00
|
|
|
private readonly navigationState = inject(NavigationState);
|
|
|
|
|
|
2025-08-29 19:19:05 +00:00
|
|
|
readonly breadcrumbItems = computed(() => {
|
2025-01-07 10:43:18 +00:00
|
|
|
const breadcrumbs: NavigationItem[] = [];
|
|
|
|
|
let activeItem = this.navigationState.activeNavigationItem()?.parent;
|
2024-07-23 16:50:12 +00:00
|
|
|
|
2025-01-07 10:43:18 +00:00
|
|
|
while (activeItem != null) {
|
|
|
|
|
breadcrumbs.push(activeItem);
|
|
|
|
|
activeItem = activeItem.parent;
|
|
|
|
|
}
|
2024-07-23 16:50:12 +00:00
|
|
|
|
2025-01-07 10:43:18 +00:00
|
|
|
return breadcrumbs.reverse();
|
|
|
|
|
});
|
2024-07-23 16:50:12 +00:00
|
|
|
}
|