NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exhibitions.vue 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template lang="pug">
  2. //- most recent upcoming exhibition - sidebar in events list - max=2?
  3. h3.t-up {{ listType }} exhibitions
  4. ul.t-up
  5. li(v-for="post in exhibitions")
  6. featured-image(:post="post", thumbsize="'standard'")
  7. router-link(:to="`/exhibition/${post.slug}`")
  8. p.t-up {{ post.title }}
  9. p {{ dateFrom(post.start, false) }} &ndash; {{ dateFrom(post.end, false) }}
  10. </template>
  11. <script>
  12. import featuredImage from '@/components/featured-image'
  13. import { postTypeGetters } from '@/pages/mixin-post-types'
  14. import { sortTypes } from '@/utils/helpers'
  15. export default {
  16. mixins: [postTypeGetters],
  17. components: { featuredImage },
  18. computed: {
  19. loaded() {
  20. return this[`allExhibitionsLoaded`]
  21. },
  22. exhibitions() {
  23. return this[`upcomingAndCurrentExhibitions`]
  24. },
  25. },
  26. data() {
  27. return {
  28. listType: 'upcoming',
  29. }
  30. },
  31. methods: {
  32. dateFrom(unix, includeTime) {
  33. const d = new Date(parseInt(unix) * 1000)
  34. return includeTime ? d.toLocaleString('en-US', { timeZone: 'UTC' }) : d.toLocaleDateString('en-US')
  35. },
  36. async getPosts() {
  37. this.$store.commit('CLEAR_EXHIBITIONS')
  38. const upcoming = this.$store.dispatch(
  39. `getAllExhibitions`,
  40. {
  41. sortType: sortTypes.currentAndUpcoming,
  42. params: {
  43. limit: 99,
  44. page: 1
  45. }
  46. }
  47. )
  48. if (upcoming.length < 1) {
  49. // this.listType = 'past'
  50. // this.$store.dispatch(`getAllExhibitions`, sortTypes.past)
  51. }
  52. },
  53. },
  54. created() {
  55. this.getPosts()
  56. },
  57. }
  58. </script>