Locorum.vue 2.6 KB

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