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 3.9KB

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