Locorum.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <MainContentLayout id="locorum" 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.country"><span class="label">Pays :</span> {{ content.country }}</p>
  11. <p v-if="content.ville"><span class="label">Ville :</span> {{ content.ville }}</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: 'Locorum',
  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. computed: {
  65. },
  66. beforeCreate () {
  67. console.log('locorum this.$route', this.$route)
  68. REST.get(`${window.apipath}/indexLocorum/` + this.$route.params.id, {})
  69. .then(({ data }) => {
  70. console.log('locorum REST: data', data)
  71. if (data.content) {
  72. this.content = data.content
  73. this.metainfotitle = data.content.title
  74. }
  75. this.updateMetaData(data.meta.metadata)
  76. })
  77. .catch((error) => {
  78. console.warn('Issue with locorum', error)
  79. Promise.reject(error)
  80. this.$router.replace({
  81. name: 'notfound',
  82. query: { fullpath: this.$route.path }
  83. })
  84. })
  85. },
  86. methods: {
  87. updateMetaData (metadata) {
  88. this.meta = []
  89. metadata.forEach(m => {
  90. let o = {}
  91. o.name = m.name
  92. if (Array.isArray(m.content)) {
  93. o.content = m.content.join(', ')
  94. } else {
  95. o.content = m.content
  96. }
  97. if (typeof m.scheme !== 'undefined') {
  98. o.scheme = m.scheme
  99. }
  100. this.meta.push(o)
  101. })
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. </style>