NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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.shadow(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.shadow(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.shadow(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.shadow(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, heroUtils } 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, heroUtils],
  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.checkAndSetHero('welcome')
  77. await this.$store.dispatch('getRandomPosts', ['episode', 'exhibition', 'event', 'artist', 'post'])
  78. },
  79. methods: {
  80. firstPostOfType(type) {
  81. return Object.values(this[`all${convertTitleCase(type)}s`])[0]
  82. },
  83. async checkAndSetHero(type) {
  84. this._clearHero(this.$store)
  85. // We always set a hero no matter what
  86. // Because the hero component will deal
  87. // with how to render based on hero.url
  88. if(!this.allPages) return console.warn('no pages in state', this)
  89. const page = this.allPages.filter(
  90. page => page.slug == type,
  91. )[0]
  92. if(!page) return console.warn(`no page for ${type} found`)
  93. this.$store.commit('SET_HERO', this._setHeroInfo(page))
  94. },
  95. },
  96. }
  97. </script>
  98. <style lang="postcss">
  99. // prettier-ignore
  100. @import '../sss/variables.sss'
  101. @import '../sss/theme.sss'
  102. .page--index
  103. > header
  104. padding: $ms-0
  105. > article
  106. display: flex
  107. justify-content: space-around
  108. flex-direction: column
  109. align-items: stretch
  110. section
  111. ul
  112. list-style: none
  113. li.post
  114. background-color: white
  115. margin: 0 0 0.65em 0
  116. .featured-or-hero-image img
  117. max-height: $max-card-img-height
  118. p.excerpt
  119. -webkit-line-clamp: calc($card-line-clamp * 2)
  120. &.max
  121. > ul
  122. grid-template-columns:
  123. auto
  124. grid-template-rows:
  125. auto
  126. /* min-width 768px */
  127. @media (min-width: $medium)
  128. .page--index
  129. > article
  130. grid-gap: $ms--2 0
  131. > section
  132. ul
  133. display: grid
  134. grid-template-columns:
  135. 49.5% 24.25% 24.25%
  136. grid-template-rows: repeat(2, 1fr)
  137. gap: 0 $ms--2
  138. li
  139. margin: 0
  140. min-height: 10em
  141. &:nth-of-type(2), &:nth-of-type(3), &:nth-of-type(4), &:nth-of-type(5)
  142. p.excerpt
  143. -webkit-line-clamp: $card-line-clamp
  144. .featured-or-hero-image img
  145. max-height: calc($max-card-img-height / 2)
  146. /* n1 episode */
  147. &:nth-of-type(1)
  148. grid-column-start: 1
  149. grid-row-start: 1
  150. grid-row-end: 3
  151. /* n2 exhibition, n3 events */
  152. &:nth-of-type(2), &:nth-of-type(3)
  153. grid-column-start: 2
  154. grid-row-start: 1
  155. &:nth-of-type(3)
  156. grid-column-start: 3
  157. /* n4 artists, n5 posts */
  158. &:nth-of-type(4), &:nth-of-type(5)
  159. grid-column-start: 2
  160. grid-row-start: 2
  161. &:nth-of-type(5)
  162. grid-column-start: 3
  163. &.max
  164. li .featured-or-hero-image img
  165. max-height: $max-card-img-height
  166. &.stickies
  167. .post
  168. min-width: 24.25%
  169. ul
  170. &.flipped
  171. grid-template-columns:
  172. 24.25% 24.25% 49.5%
  173. li
  174. &:nth-of-type(1)
  175. grid-row-end: 2
  176. &:nth-of-type(3)
  177. grid-column-start: 1
  178. grid-row-start: 2
  179. &:nth-of-type(5)
  180. grid-row-start: 1
  181. grid-row-end: 3
  182. &[class^="sticky-"]
  183. display: flex
  184. &.sticky-1
  185. > li .card--info
  186. display: flex
  187. > a:first-of-type
  188. width: 100%
  189. &.sticky-5
  190. grid-template-columns:
  191. 24.25% 24.25% 49.5%
  192. grid-template-rows:
  193. repeat(2, 1fr)
  194. gap: 3% 1%
  195. > li
  196. &:nth-of-type(1)
  197. grid-row-end: 2
  198. &:nth-of-type(2)
  199. grid-column-start: 2
  200. grid-row-start: 1
  201. grid-row-end: 2
  202. &:nth-of-type(3)
  203. grid-column-start: 1
  204. grid-row-start: 2
  205. margin: 0 0 8% 0
  206. &:nth-of-type(4)
  207. grid-column-start: 2
  208. grid-row-start: 2
  209. margin: 0 0 8% 0
  210. &:nth-of-type(5)
  211. grid-column-start: 3
  212. margin: 0 0 4% 0
  213. </style>