Locorum.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. </MainContentLayout>
  31. </template>
  32. <script>
  33. import { REST } from 'api/rest-axios'
  34. import MainContentLayout from '../components/Layouts/MainContentLayout'
  35. import IndexItemOcurrences from '../components/Content/IndexItemOcurrences'
  36. export default {
  37. name: 'Locorum',
  38. components: {
  39. MainContentLayout,
  40. IndexItemOcurrences
  41. },
  42. data: () => ({
  43. content: null,
  44. meta: [],
  45. metainfotitle: undefined
  46. }),
  47. metaInfo () {
  48. // console.log('metainfo', this.meta)
  49. return {
  50. title: this.metainfotitle,
  51. meta: this.meta
  52. }
  53. },
  54. computed: {
  55. },
  56. beforeCreate () {
  57. console.log('locorum this.$route', this.$route)
  58. REST.get(`${window.apipath}/indexLocorum/` + this.$route.params.id, {})
  59. .then(({ data }) => {
  60. console.log('locorum REST: data', data)
  61. if (data.content) {
  62. this.content = data.content
  63. this.metainfotitle = data.content.title
  64. }
  65. this.updateMetaData(data.meta.metadata)
  66. })
  67. .catch((error) => {
  68. console.warn('Issue with locorum', error)
  69. Promise.reject(error)
  70. this.$router.replace({
  71. name: 'notfound',
  72. query: { fullpath: this.$route.path }
  73. })
  74. })
  75. },
  76. methods: {
  77. updateMetaData (metadata) {
  78. this.meta = []
  79. metadata.forEach(m => {
  80. let o = {}
  81. o.name = m.name
  82. if (Array.isArray(m.content)) {
  83. o.content = m.content.join(', ')
  84. } else {
  85. o.content = m.content
  86. }
  87. if (typeof m.scheme !== 'undefined') {
  88. o.scheme = m.scheme
  89. }
  90. this.meta.push(o)
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. </style>