Operum.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <MainContentLayout id="operum" class="index-item">
  3. <template v-if="!content" v-slot:header>
  4. <span class="loading">Chargement ...</span>
  5. </template>
  6. <template v-if="content" v-slot:header>
  7. <h1 v-html="content.title" />
  8. <section v-if="content.author.length" class="authors">
  9. <ul>
  10. <li v-for="author in content.author" :key="author.uuid">
  11. <router-link
  12. :to="{ name:'nominum', params: { id: author.uuid }}"
  13. >
  14. {{ author.name }}
  15. </router-link>
  16. </li>
  17. </ul>
  18. </section>
  19. <section class="notes">
  20. <div v-for="(note, i) in content.note" :key="i" class="note" v-html="note" />
  21. </section>
  22. <section v-if="content.autorities.length" class="autorities">
  23. <h3>Autorities</h3>
  24. <ul>
  25. <li v-for="(aut, i) in content.autorities" :key="i">
  26. <a :href="aut.identifier" target="_blanck">
  27. {{ aut.autority }}
  28. <span class="mdi mdi-open-in-new" />
  29. </a>
  30. </li>
  31. </ul>
  32. </section>
  33. </template>
  34. <!-- default slot -->
  35. <IndexItemOcurrences v-if="content" :content="content" />
  36. </MainContentLayout>
  37. </template>
  38. <script>
  39. import { REST } from 'api/rest-axios'
  40. import MainContentLayout from '../components/Layouts/MainContentLayout'
  41. import IndexItemOcurrences from '../components/Content/IndexItemOcurrences'
  42. export default {
  43. name: 'Operum',
  44. components: {
  45. MainContentLayout,
  46. IndexItemOcurrences
  47. },
  48. data: () => ({
  49. content: null,
  50. meta: [],
  51. metainfotitle: undefined
  52. }),
  53. metaInfo () {
  54. // console.log('metainfo', this.meta)
  55. return {
  56. title: this.metainfotitle,
  57. meta: this.meta
  58. }
  59. },
  60. beforeCreate () {
  61. console.log('operum this.$route', this.$route)
  62. REST.get(`${window.apipath}/indexOperum/` + this.$route.params.id, {})
  63. .then(({ data }) => {
  64. console.log('operum REST: data', data)
  65. if (data.content) {
  66. this.content = data.content
  67. this.metainfotitle = data.content.title
  68. }
  69. this.updateMetaData(data.meta.metadata)
  70. })
  71. .catch((error) => {
  72. console.warn('Issue with operum', error)
  73. Promise.reject(error)
  74. this.$router.replace({
  75. name: 'notfound',
  76. query: { fullpath: this.$route.path }
  77. })
  78. })
  79. },
  80. methods: {
  81. updateMetaData (metadata) {
  82. this.meta = []
  83. metadata.forEach(m => {
  84. let o = {}
  85. o.name = m.name
  86. if (Array.isArray(m.content)) {
  87. o.content = m.content.join(', ')
  88. } else {
  89. o.content = m.content
  90. }
  91. if (typeof m.scheme !== 'undefined') {
  92. o.scheme = m.scheme
  93. }
  94. this.meta.push(o)
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. </style>