Skip to content

Commit ccb0b83

Browse files
author
Mark von Zeschau
committed
Make breadcrumbs dynamic, i.e. now they may be functions.
In doing so it's possible to e.g. update the breadcrumbs when changing the language.
1 parent 7a0ec7f commit ccb0b83

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/vue-2-breadcrumbs.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ export default {
99
});
1010

1111
Vue.component('breadcrumbs', {
12+
methods: {
13+
getBreadcrumb: function getBreadcrumb(bc) {
14+
return typeof bc === 'function' ? bc() : bc
15+
},
16+
},
1217
template: `
1318
<ol class="breadcrumb" v-if="$breadcrumbs.length">
1419
<li class="breadcrumb-item" v-if="crumb.meta.breadcrumb" v-for="(crumb, i) in $breadcrumbs">
15-
<router-link active-class="active" :to="{ path: crumb.path }" :tag="i != $breadcrumbs.length - 1 ? 'a' : 'span'">{{ crumb.meta.breadcrumb }}</router-link>
20+
<router-link active-class="active" :to="{ path: crumb.path }" :tag="i != $breadcrumbs.length - 1 ? 'a' : 'span'">{{ getBreadcrumb(crumb.meta.breadcrumb) }}</router-link>
1621
</li>
1722
</ol>
1823
`

0 commit comments

Comments
 (0)