ArticleCard.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <article class="card article">
  3. <header>
  4. <h1>
  5. <a
  6. :href="item.view_node"
  7. @click.prevent="onclick"
  8. v-html="item.title"
  9. ></a>
  10. </h1>
  11. <aside v-html="item.created"></aside>
  12. <h4 v-if="false" class="body" v-html="item.body"></h4>
  13. </header>
  14. <section class="images">
  15. <figure v-if="item.field_title_image !== ''" v-html="item.field_title_image"></figure>
  16. <figure v-else-if="item.field_visuel !== ''" v-html="item.field_visuel"></figure>
  17. </section>
  18. </article>
  19. </template>
  20. <script>
  21. import { JSONAPI } from 'vuejs/api/json-axios'
  22. import router from 'vuejs/route'
  23. let basePath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix;
  24. export default {
  25. name: "ArticleCard",
  26. router,
  27. props: ['item'],
  28. data(){
  29. return {
  30. alias: this.item.view_node.replace(/^.?\/blabla\//g, '')
  31. }
  32. },
  33. methods:{
  34. onclick(){
  35. console.log('clicked on article', this.alias);
  36. this.$router.push({
  37. name:`article`,
  38. params: { alias:this.alias },
  39. query: { uuid: this.item.uuid }
  40. // meta: { uuid:this.item.uuid },
  41. })
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. </style>