Made breadcrumbs reactive
This commit is contained in:
parent
7b1ce9cb23
commit
a7f75868cf
6 changed files with 55 additions and 6 deletions
24
app/stores/breadcrumbs.ts
Normal file
24
app/stores/breadcrumbs.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { defineStore } from "pinia";
|
||||
|
||||
export interface BreadcrumbItem {
|
||||
label: string;
|
||||
to?: string;
|
||||
}
|
||||
|
||||
export const useBreadcrumbStore = defineStore("breadcrumb", {
|
||||
state: () => ({
|
||||
items: [] as BreadcrumbItem[],
|
||||
}),
|
||||
|
||||
actions: {
|
||||
setBreadcrumbs(items: BreadcrumbItem[]) {
|
||||
this.items = items;
|
||||
},
|
||||
addBreadcrumb(item: BreadcrumbItem) {
|
||||
this.items.push(item);
|
||||
},
|
||||
clear() {
|
||||
this.items = [];
|
||||
},
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue