Operum.vue 3.1 KB

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