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.

index.vue 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // Homepage grid
  2. <template lang="pug">
  3. .page--index.f-row.between
  4. article.w-max
  5. section(v-if="allSticky && Object.keys(allSticky).length").stickies
  6. ul.flipped(:class="[`sticky-${Object.keys(allSticky).length}`]")
  7. //- if sticky
  8. li.shadow(v-for="sticky in allSticky")
  9. card(:content="sticky" :type="`${sticky.type}s`")
  10. section
  11. ul
  12. li.shadow(v-for="type in ['episodes', 'exhibitions', 'events', 'artists', 'posts']")
  13. card(:content="firstPostOfType(type)" :type="type")
  14. section.max
  15. ul.w-max
  16. li.shadow(v-for="post in [randomPostOfType('artists')]")
  17. card(v-if="post" :content="post" :type="`${post.type}s`" :wide="true")
  18. section
  19. ul.flipped
  20. li.shadow(v-for="type in ['episodes', 'exhibitions', 'events', 'artists', 'artists']")
  21. .random--wrapper(v-for="post in [randomPostOfType(type)]")
  22. card(:content="post" :type="type")
  23. </template>
  24. <script>
  25. import { postTypeGetters, scrollTop } from './mixin-post-types'
  26. import card from '@/components/card.vue'
  27. import { convertTitleCase, postTypes } from '@/utils/helpers'
  28. export default {
  29. mixins: [postTypeGetters, scrollTop],
  30. components: { card },
  31. created() {
  32. // console.log(wp)
  33. postTypes.forEach(type => {
  34. const capitalizedType = convertTitleCase(type)
  35. this.$store.dispatch(`getAll${capitalizedType}`)
  36. })
  37. this.checkAndSetHero('welcome')
  38. },
  39. methods: {
  40. async checkAndSetHero(type) {
  41. if(!this['allPagesLoaded']) {
  42. await this.$store.dispatch('getAllPages')
  43. }
  44. const page = this.allPages[type]
  45. if(!page) return
  46. let json = { url: page.featured, heroType: 'image' }
  47. if(page.hero && JSON.parse(page.hero) && JSON.parse(page.hero).url) {
  48. json = JSON.parse(page.hero)
  49. json.heroType = 'video'
  50. }
  51. this.$store.commit('SET_HERO', json)
  52. },
  53. firstPostOfType(type) {
  54. return Object.values(this[`all${convertTitleCase(type)}`])[0]
  55. },
  56. randomPostOfType(type) {
  57. const postsOfType = Object.values(this[`all${convertTitleCase(type)}`])
  58. const max = postsOfType.length
  59. const rand = Math.floor(Math.random() * max)
  60. return postsOfType[rand]
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="postcss">
  66. @import '../sss/variables.sss'
  67. @import '../sss/theme.sss'
  68. .page--index > article
  69. display: flex
  70. justify-content: space-around
  71. flex-direction: column
  72. align-items: stretch
  73. section
  74. ul
  75. list-style: none
  76. li
  77. margin: 0 0 $ms-0 0
  78. &.max
  79. margin: 0
  80. > ul
  81. grid-template-columns:
  82. auto
  83. grid-template-rows:
  84. auto
  85. @media (min-width: $medium)
  86. .page--index > article > section
  87. &.stickies
  88. margin: 0 0 2% 0
  89. &.max
  90. margin: 3.5% 0 3% 0
  91. ul
  92. display: grid
  93. grid-template-columns:
  94. 49.5% 24.25% 24.25%
  95. grid-template-rows:
  96. 48% 48%
  97. gap: 4% 1%
  98. li
  99. margin: 0
  100. min-height: 10em
  101. background-color: purple
  102. &:nth-of-type(1)
  103. grid-column-start: 1
  104. grid-row-start: 1
  105. grid-row-end: 3
  106. &:nth-of-type(2), &:nth-of-type(3)
  107. grid-column-start: 2
  108. grid-row-start: 1
  109. &:nth-of-type(3)
  110. grid-column-start: 3
  111. &:nth-of-type(4), &:nth-of-type(5)
  112. grid-column-start: 2
  113. grid-row-start: 2
  114. &:nth-of-type(5)
  115. grid-column-start: 3
  116. &.stickies
  117. ul
  118. &.flipped
  119. grid-template-columns:
  120. 24.25% 24.25% 49.5%
  121. li
  122. &:nth-of-type(1)
  123. grid-row-end: 2
  124. &:nth-of-type(3)
  125. grid-column-start: 1
  126. grid-row-start: 2
  127. &:nth-of-type(5)
  128. grid-row-start: 1
  129. grid-row-end: 3
  130. &.sticky-1
  131. display: flex
  132. > li .card--info
  133. display: flex
  134. > a:first-of-type
  135. width: 100%
  136. &.sticky-2
  137. display: flex
  138. &.sticky-3
  139. display: flex
  140. &.sticky-4
  141. display: flex
  142. &.sticky-5
  143. grid-template-columns:
  144. 24.25% 24.25% 49.5%
  145. grid-template-rows:
  146. 48% 48%
  147. gap: 4% 1%
  148. > li
  149. &:nth-of-type(1)
  150. grid-row-end: 2
  151. &:nth-of-type(2)
  152. grid-column-start: 2
  153. grid-row-start: 1
  154. grid-row-end: 2
  155. &:nth-of-type(3)
  156. grid-column-start: 1
  157. grid-row-start: 2
  158. margin: 0 0 8% 0
  159. &:nth-of-type(4)
  160. grid-column-start: 2
  161. grid-row-start: 2
  162. margin: 0 0 8% 0
  163. &:nth-of-type(5)
  164. grid-column-start: 3
  165. margin: 0 0 4% 0
  166. </style>