Bibliographie.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <MainContentLayout id="biblio">
  3. <template v-if="!content" #header>
  4. <span>Loading ...</span>
  5. </template>
  6. <template #header>
  7. <h1>
  8. <router-link :to="{ name:'bibliographie'}">Bibliographie</router-link>
  9. </h1>
  10. <nav>
  11. <ul>
  12. <li>
  13. <router-link
  14. :to="{ name:'bibliographie', params: { type: 'expressions'}}"
  15. >
  16. Expressions
  17. </router-link>
  18. </li>
  19. <li>
  20. <router-link
  21. :to="{ name:'bibliographie', params: { type: 'manifestations'}}"
  22. >
  23. Manifestations
  24. </router-link>
  25. </li>
  26. </ul>
  27. </nav>
  28. </template>
  29. <!-- default slot -->
  30. <!-- expressions or manifestations list -->
  31. <template v-if="!uuid">
  32. <ul class="item-list">
  33. <li v-for="item in content" :key="item.uuid">
  34. <h2>
  35. <router-link
  36. :to="{ name:'bibliographieItem', params:{ type:type, uuid:item.uuid } }"
  37. >
  38. {{ item.authors }}
  39. </router-link>
  40. </h2>
  41. <p class="date">{{ item.dates }}</p>
  42. <p class="titles">{{ item.titles }}</p>
  43. </li>
  44. </ul>
  45. </template>
  46. <!-- or item -->
  47. <template v-else>
  48. <div class="biblio-item">
  49. <h2>{{ content.authors }}</h2>
  50. <p v-if="content.dates" class="date">{{ content.dates }}</p>
  51. <p class="titles">{{ content.titles }}</p>
  52. <ul vi-if="content.manifestations.length" class="item-list">
  53. <li v-for="item in content.manifestations" :key="item.uuid">
  54. <router-link
  55. :to="{ name:'bibliographieItem', params:{ type:'manifestations', uuid:item.uuid } }"
  56. v-html="item.tei"
  57. />
  58. </li>
  59. </ul>
  60. </div>
  61. </template>
  62. <template #nav />
  63. </MainContentLayout>
  64. </template>
  65. <script>
  66. import { REST } from 'api/rest-axios'
  67. import MainContentLayout from '../components/Layouts/MainContentLayout'
  68. export default {
  69. name: 'Bibliographie',
  70. components: {
  71. MainContentLayout
  72. },
  73. metaInfo: {
  74. title: 'Bibliographie'
  75. },
  76. props: {
  77. type: String,
  78. uuid: String
  79. },
  80. data: () => ({
  81. content: Array
  82. }),
  83. watch: {
  84. $route (to, from) {
  85. this.getContent()
  86. }
  87. },
  88. created () {
  89. // this.type = this.$route.params.type || 'expressions'
  90. // this.uuid = this.$route.params.id || null
  91. this.getContent()
  92. },
  93. methods: {
  94. getContent () {
  95. // ?_format=json
  96. REST.get(`${window.apipath}/bibliography/${this.type}/${this.uuid || ''}`, {})
  97. .then(({ data }) => {
  98. console.log('Biblio REST: data', data)
  99. if (data.content) {
  100. this.content = data.content
  101. }
  102. })
  103. .catch((error) => {
  104. console.warn('Issue with bibliographie', error)
  105. Promise.reject(error)
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. </style>