NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

index.vue 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. // Homepage grid
  2. <template lang="pug">
  3. .page--index.f-col.between
  4. header.w-max(v-if="allPages.welcome")
  5. .page-content(v-html="allPages.welcome.content")
  6. article.w-max
  7. //- sticky section
  8. section(v-if="allSticky && Object.keys(allSticky).length").stickies
  9. ul(:class="[`sticky-${Object.keys(allSticky).length}`, 'flipped']")
  10. //- if sticky
  11. li.post(v-for="sticky in allSticky")
  12. card(:content="sticky" :type="`${sticky.type}`")
  13. //- firstRow: ['episodes', 'exhibitions', 'events', 'shorts', 'posts'], exceprt on episodes only.
  14. section
  15. ul
  16. li.post(v-for="type in firstRow")
  17. card(:content="firstPostOfType(type)" :type="type")
  18. //- secondRow: 'artists', // This is only ONE post, excerpt on artist
  19. section.max
  20. ul.w-max
  21. li.post(v-for="post in randomPosts.filter(p => p.type == secondRow)")
  22. card(v-if="post" :content="post" :type="`${post.type}`" :wide="true")
  23. //- (thirdRow) firstRow.flipped: ['guides', 'objects', 'techniques', 'talks', 'center'], exceprt on guides only
  24. section
  25. ul.flipped
  26. li.post(v-for="type in thirdRow")
  27. .random--wrapper(v-for="post in randomPosts.filter(p => p.type == type)")
  28. card(:content="post" :type="type")
  29. </template>
  30. <script>
  31. import { postTypeGetters, scrollTop } from './mixin-post-types'
  32. import card from '@/components/card.vue'
  33. import { convertTitleCase, postTypes, sortTypes } from '@/utils/helpers'
  34. export default {
  35. mixins: [postTypeGetters, scrollTop],
  36. components: { card },
  37. data() {
  38. return {
  39. firstRow: ['episode', 'exhibition', 'event', 'artist', 'post'],
  40. secondRow: 'artist', // This is only ONE post
  41. thirdRow: ['episode', 'exhibition', 'event', 'artist', 'post'],
  42. }
  43. },
  44. async created() {
  45. // console.log(wp)
  46. const omit = ['page']
  47. for (let type of postTypes) {
  48. const action = `getAll${convertTitleCase(type)}s`
  49. // Limit the amount of posts because we
  50. // only need the most recent
  51. const params = { limit: 1 }
  52. // We try and fetch EVERYTHING except
  53. // for EVENTS and EXHIBITIONS
  54. if (['event', 'exhibition'].includes(type)) {
  55. // Only grab the current or upcoming on load
  56. const eventsOrExhibitions = await this.$store.dispatch(
  57. action,
  58. {
  59. sortType: sortTypes.currentAndUpcoming,
  60. params
  61. }
  62. )
  63. // If no current or upcoming, get past events
  64. // to fill in the blanks
  65. if (eventsOrExhibitions.length < 1) {
  66. this.$store.dispatch(action, { sortType: sortTypes.past, params })
  67. }
  68. }
  69. else if (!omit.includes(type)){
  70. this.$store.dispatch(action, { sortType: null, params })
  71. }
  72. }
  73. if (!this['allPagesLoaded']) {
  74. await this.$store.dispatch('getAllPages', { sortType: null, params: null })
  75. }
  76. await this.$store.dispatch('getRandomPosts', ['episode', 'exhibition', 'event', 'artist', 'post'])
  77. },
  78. methods: {
  79. firstPostOfType(type) {
  80. return Object.values(this[`all${convertTitleCase(type)}s`])[0]
  81. },
  82. },
  83. }
  84. </script>
  85. <style lang="postcss">
  86. // prettier-ignore
  87. @import '../sss/variables.sss'
  88. @import '../sss/theme.sss'
  89. .page--index
  90. > header
  91. padding: $ms-0
  92. > article
  93. display: flex
  94. justify-content: space-around
  95. flex-direction: column
  96. align-items: stretch
  97. section
  98. ul
  99. list-style: none
  100. li.post
  101. background-color: white
  102. .featured-or-hero-image img
  103. max-height: $max-card-img-height
  104. p.excerpt
  105. -webkit-line-clamp: calc($card-line-clamp * 2)
  106. &.max
  107. > ul
  108. grid-template-columns:
  109. auto
  110. grid-template-rows:
  111. auto
  112. /* min-width 768px */
  113. @media (min-width: $medium)
  114. .page--index > article > section
  115. ul
  116. display: grid
  117. grid-template-columns:
  118. 49.5% 24.25% 24.25%
  119. grid-template-rows:
  120. 48% 48%
  121. gap: 2% 1%
  122. li
  123. margin: 0
  124. min-height: 10em
  125. &:nth-of-type(2), &:nth-of-type(3), &:nth-of-type(4), &:nth-of-type(5)
  126. p.excerpt
  127. -webkit-line-clamp: $card-line-clamp
  128. .featured-or-hero-image img
  129. max-height: calc($max-card-img-height / 2)
  130. /* n1 episode */
  131. &:nth-of-type(1)
  132. grid-column-start: 1
  133. grid-row-start: 1
  134. grid-row-end: 3
  135. /* n2 exhibition, n3 events */
  136. &:nth-of-type(2), &:nth-of-type(3)
  137. grid-column-start: 2
  138. grid-row-start: 1
  139. &:nth-of-type(3)
  140. grid-column-start: 3
  141. /* n4 artists, n5 posts */
  142. &:nth-of-type(4), &:nth-of-type(5)
  143. grid-column-start: 2
  144. grid-row-start: 2
  145. &:nth-of-type(5)
  146. grid-column-start: 3
  147. &.max
  148. /* Need some extra gap on wide pages */
  149. padding: $ms--2 0
  150. li .featured-or-hero-image img
  151. max-height: $max-card-img-height
  152. &.stickies
  153. .post
  154. min-width: 24.25%
  155. ul
  156. &.flipped
  157. grid-template-columns:
  158. 24.25% 24.25% 49.5%
  159. li
  160. &:nth-of-type(1)
  161. grid-row-end: 2
  162. &:nth-of-type(3)
  163. grid-column-start: 1
  164. grid-row-start: 2
  165. &:nth-of-type(5)
  166. grid-row-start: 1
  167. grid-row-end: 3
  168. &[class^="sticky-"]
  169. display: flex
  170. &.sticky-1
  171. > li .card--info
  172. display: flex
  173. > a:first-of-type
  174. width: 100%
  175. &.sticky-5
  176. grid-template-columns:
  177. 24.25% 24.25% 49.5%
  178. grid-template-rows:
  179. 48% 48%
  180. gap: 3% 1%
  181. > li
  182. &:nth-of-type(1)
  183. grid-row-end: 2
  184. &:nth-of-type(2)
  185. grid-column-start: 2
  186. grid-row-start: 1
  187. grid-row-end: 2
  188. &:nth-of-type(3)
  189. grid-column-start: 1
  190. grid-row-start: 2
  191. margin: 0 0 8% 0
  192. &:nth-of-type(4)
  193. grid-column-start: 2
  194. grid-row-start: 2
  195. margin: 0 0 8% 0
  196. &:nth-of-type(5)
  197. grid-column-start: 3
  198. margin: 0 0 4% 0
  199. </style>