Corpus.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <MainContentLayout id="corpus">
  3. <template v-if="!content" v-slot:header>
  4. <span>Loading ...</span>
  5. </template>
  6. <template v-if="content" v-slot:header>
  7. <h1>{{ meta.author }}</h1>
  8. <h2>{{ meta.quantity }}</h2>
  9. </template>
  10. <section
  11. v-for="item in content"
  12. :key="item.uuid"
  13. >
  14. <h3>
  15. <a
  16. :uuid="item.uuid"
  17. :href="item.url"
  18. @click.prevent="onclick"
  19. @keyup.enter="onclick"
  20. >
  21. {{ item.title }}
  22. </a>
  23. </h3>
  24. <p class="date">{{ item.date }}</p>
  25. <p class="format"><span>format:</span> {{ item.format }}</p>
  26. <p class="itemsNb"><span>itemsNb:</span> {{ item.itemsNb }}</p>
  27. <p class="otherEditions"><span>Other Editions:</span> {{ item.otherEditions }}</p>
  28. <p class="biblio">{{ item.biblio }}</p>
  29. </section>
  30. <template v-slot:nav />
  31. </MainContentLayout>
  32. </template>
  33. <script>
  34. import { REST } from 'api/rest-axios'
  35. import MainContentLayout from '../components/Layouts/MainContentLayout'
  36. export default {
  37. name: 'Corpus',
  38. components: {
  39. MainContentLayout
  40. },
  41. data: () => ({
  42. content: null,
  43. meta: null
  44. }),
  45. beforeCreate () {
  46. console.log('corpus this.$route', this.$route)
  47. REST.get(`/corpus/` + this.$route.params.id, {})
  48. .then(({ data }) => {
  49. console.log('corpus REST: data', data)
  50. this.meta = data.meta
  51. if (data.content) {
  52. if (Array.isArray(data.content)) {
  53. this.content = data.content
  54. } else {
  55. this.content = [data.content]
  56. }
  57. }
  58. })
  59. .catch((error) => {
  60. console.warn('Issue with locorum', error)
  61. Promise.reject(error)
  62. })
  63. },
  64. methods: {
  65. onclick (e) {
  66. console.log('clicked on corpus', e)
  67. this.$router.push({
  68. name: `texts`,
  69. params: { id: e.target.getAttribute('uuid') }
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. </style>