You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BreadCrumbs.vue 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <NcBreadcrumbs data-cy-files-content-breadcrumbs>
  3. <!-- Current path sections -->
  4. <NcBreadcrumb v-for="section in sections"
  5. :key="section.dir"
  6. :aria-label="t('files', `Go to the '{dir}' directory`, section)"
  7. v-bind="section" />
  8. </NcBreadcrumbs>
  9. </template>
  10. <script>
  11. import NcBreadcrumbs from '@nextcloud/vue/dist/Components/NcBreadcrumbs.js'
  12. import NcBreadcrumb from '@nextcloud/vue/dist/Components/NcBreadcrumb.js'
  13. import { basename } from 'path'
  14. export default {
  15. name: 'BreadCrumbs',
  16. components: {
  17. NcBreadcrumbs,
  18. NcBreadcrumb,
  19. },
  20. props: {
  21. path: {
  22. type: String,
  23. default: '/',
  24. },
  25. },
  26. computed: {
  27. dirs() {
  28. const cumulativePath = (acc) => (value) => (acc += `${value}/`)
  29. return ['/', ...this.path.split('/').filter(Boolean).map(cumulativePath('/'))]
  30. },
  31. sections() {
  32. return this.dirs.map(dir => {
  33. const to = { ...this.$route, query: { dir } }
  34. return {
  35. dir,
  36. to,
  37. title: basename(dir),
  38. }
  39. })
  40. },
  41. },
  42. }
  43. </script>
  44. <style lang="scss" scoped>
  45. .breadcrumb {
  46. // Take as much space as possible
  47. flex: 1 1 100% !important;
  48. width: 100%;
  49. }
  50. </style>