Skip to content

Commit

Permalink
Make breadcrumbs dynamic, i.e. now they may be functions.
Browse files Browse the repository at this point in the history
In doing so it's possible to e.g. update the breadcrumbs when changing the language.
  • Loading branch information
Mark von Zeschau committed Jan 29, 2018
1 parent 7a0ec7f commit ccb0b83
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/vue-2-breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ export default {
});

Vue.component('breadcrumbs', {
methods: {
getBreadcrumb: function getBreadcrumb(bc) {
return typeof bc === 'function' ? bc() : bc
},
},
template: `
<ol class="breadcrumb" v-if="$breadcrumbs.length">
<li class="breadcrumb-item" v-if="crumb.meta.breadcrumb" v-for="(crumb, i) in $breadcrumbs">
<router-link active-class="active" :to="{ path: crumb.path }" :tag="i != $breadcrumbs.length - 1 ? 'a' : 'span'">{{ crumb.meta.breadcrumb }}</router-link>
<router-link active-class="active" :to="{ path: crumb.path }" :tag="i != $breadcrumbs.length - 1 ? 'a' : 'span'">{{ getBreadcrumb(crumb.meta.breadcrumb) }}</router-link>
</li>
</ol>
`
Expand Down

0 comments on commit ccb0b83

Please sign in to comment.