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.

card.vue 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template lang="pug">
  2. .card(v-if="content")
  3. header
  4. router-link(v-if="!hideType && ['event','exhibition'].includes(type)" :to="`/${type}/sorted/by-current-and-upcoming`")
  5. h4.t-up {{type}}
  6. router-link(v-else-if="type == 'post'" :to="`/blog`")
  7. h4.t-up blog
  8. router-link(v-else-if="!hideType" :to="`/${type}`")
  9. h4.t-up {{type}}
  10. article.card--info(:class="{ 'wide': wide }")
  11. router-link(v-if="type == 'post'" :to="`/blog/${content.slug}`")
  12. featured-image(:post="content", thumbsize="'standard'")
  13. router-link(v-else :to="`/${type}/${content.slug}`")
  14. //- set image to thumbnail setting
  15. featured-image(:post="content", thumbsize="'standard'")
  16. .f-col.w-max(style="height: inherit")
  17. router-link(v-if="type == 'post'" :to="`/blog/${content.slug}`")
  18. h1.t-up.t-cntr.t-b {{ content.title }}
  19. router-link(v-else :to="`/${type}/${content.slug}`")
  20. h1.t-up.t-cntr.t-b {{ content.title }}
  21. //- if events display: date, time-time
  22. p(v-if="content.end && type == 'event'" class="datetime") {{ dateFrom(content.start, type=='event') }} &ndash; {{ dateFrom(content.end, type=='event').split(',')[1] }}
  23. //- if post display: date
  24. p(v-if="content.date && type == 'post'" class="datetime") {{ dateFrom((new Date(content.date).getTime()/1000), type=='post').split(',')[0] }}
  25. //- else-if exhibition display: date-date
  26. p(v-else-if="content.end && type == 'exhibition'" class="datetime") {{ dateFrom(content.start) }} &ndash; {{ dateFrom(content.end) }}
  27. p(v-html="content.excerpt").excerpt
  28. router-link(v-if="type == 'post'" :to="`/blog/${content.slug}`")
  29. p.read-more read more
  30. router-link(v-else :to="`/${type}/${content.slug}`")
  31. p.read-more read more
  32. </template>
  33. <script>
  34. import featuredImage from '@/components/featured-image'
  35. import { formatDate } from '@/utils/helpers'
  36. export default {
  37. components: { featuredImage },
  38. props: ['type', 'content', 'wide', 'hide-type'],
  39. methods: {
  40. dateFrom: (unix, includeTime) => formatDate(unix, includeTime),
  41. }
  42. }
  43. </script>
  44. <style lang="postcss">
  45. // prettier-ignore
  46. @import '../sss/variables.sss'
  47. @import '../sss/theme.sss'
  48. .card
  49. background-color: white
  50. padding: $ms--1
  51. min-height: 220px
  52. overflow: hidden
  53. text-overflow: clip
  54. &--info
  55. display: flex
  56. flex-direction: column
  57. > a
  58. line-height: 0
  59. /* Force crop images */
  60. .featured-or-hero-image img
  61. object-fit: cover
  62. object-position: 0% 30%
  63. max-height: calc($max-card-img-height / 3)
  64. overflow-y: clip
  65. width: 100%
  66. header a
  67. font-size: $ms--2
  68. text-decoration: none
  69. margin: 0
  70. p
  71. margin: 0
  72. img
  73. width: 100%
  74. height: auto
  75. h1, h2, h3
  76. padding: $ms--3
  77. margin: 0
  78. h1
  79. font-size: $ms-1
  80. padding: 0
  81. line-height: initial
  82. display: -webkit-box
  83. -webkit-line-clamp: $card-line-clamp
  84. -webkit-box-orient: vertical
  85. overflow-y: clip
  86. margin: $ms--2 0 0 0
  87. p
  88. &.datetime
  89. font-size: $ms--1
  90. margin: $ms-0
  91. &.excerpt, &.read-more
  92. display: none
  93. /* for widths larger than 768px */
  94. @media (min-width: $medium)
  95. .is-grid .card
  96. &--info
  97. .featured-or-hero-image img
  98. max-height: calc($max-card-img-height / 3)
  99. .card
  100. min-height: 305px
  101. &--info
  102. .featured-or-hero-image img
  103. max-height: $max-card-img-height
  104. p
  105. &.excerpt, &.read-more
  106. overflow: hidden
  107. margin: $ms--2 0 0 0
  108. -webkit-line-clamp: $card-line-clamp
  109. -webkit-box-orient: vertical
  110. display: -webkit-box
  111. .wide
  112. padding: 0
  113. flex-direction: row
  114. grid-gap: $ms--2
  115. /* Featured image link */
  116. > a
  117. width: 100%
  118. </style>