D
D
Dmitry2018-02-04 21:24:30
JavaScript
Dmitry, 2018-02-04 21:24:30

Breadcrumbs on nuxt.js?

Maybe someone knows about the finished component or is there any guide on how to make "breadcrumbs" on nuxt?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grinat, 2018-02-19
@grinat

<template lang="pug">
  div.breadcrumbs
    router-link(
      v-for="link, i in breadcrumbsLinks"
      :key="i"
      :to="link"
    ).breadcrumps__level {{link.meta.title}}
</template>

<script>
  export default {
    name: 'breadcrumbs',
    computed: {
      breadcrumbsLinks () {
        let tmp = []
        if (this.$route.matched) {
          this.$route.matched.forEach(link => {
            tmp.push(Object.assign({meta: {title: 'Title not found in meta'}}, link))
          })
        }
        if (tmp.length === 0) {
          tmp.push({path: '/', meta: {title: 'Home'}})
        }
        return tmp
      }
    }
  }
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question