Преглед изворни кода

:sparkles: adding hero to welcome

tags/0.9.0
J пре 4 година
родитељ
комит
fae623070e
1 измењених фајлова са 17 додато и 2 уклоњено
  1. 17
    2
      vue-theme/src/pages/index.vue

+ 17
- 2
vue-theme/src/pages/index.vue Прегледај датотеку

33
 </template>
33
 </template>
34
 
34
 
35
 <script>
35
 <script>
36
-import { postTypeGetters, scrollTop } from './mixin-post-types'
36
+import { postTypeGetters, scrollTop, heroUtils } from './mixin-post-types'
37
 import card from '@/components/card.vue'
37
 import card from '@/components/card.vue'
38
 
38
 
39
 import { convertTitleCase, postTypes, sortTypes } from '@/utils/helpers'
39
 import { convertTitleCase, postTypes, sortTypes } from '@/utils/helpers'
40
 
40
 
41
 export default {
41
 export default {
42
-    mixins: [postTypeGetters, scrollTop],
42
+    mixins: [postTypeGetters, scrollTop, heroUtils],
43
     components: { card },
43
     components: { card },
44
     data() {
44
     data() {
45
         return {
45
         return {
82
         if (!this['allPagesLoaded']) {
82
         if (!this['allPagesLoaded']) {
83
             await this.$store.dispatch('getAllPages', { sortType: null, params: null })
83
             await this.$store.dispatch('getAllPages', { sortType: null, params: null })
84
         }
84
         }
85
+        await this.checkAndSetHero('welcome')
85
         await this.$store.dispatch('getRandomPosts', ['episode', 'exhibition', 'event', 'artist', 'post'])
86
         await this.$store.dispatch('getRandomPosts', ['episode', 'exhibition', 'event', 'artist', 'post'])
86
     },
87
     },
87
     methods: {
88
     methods: {
88
         firstPostOfType(type) {
89
         firstPostOfType(type) {
89
             return Object.values(this[`all${convertTitleCase(type)}s`])[0]
90
             return Object.values(this[`all${convertTitleCase(type)}s`])[0]
90
         },
91
         },
92
+        async checkAndSetHero(type) {
93
+            this._clearHero(this.$store)
94
+
95
+            // We always set a hero no matter what
96
+            // Because the hero component will deal
97
+            // with how to render based on hero.url
98
+            if(!this.allPages) return console.warn('no pages in state', this)
99
+            const page = this.allPages.filter(
100
+                page => page.slug == type,
101
+            )[0]
102
+            if(!page) return console.warn(`no page for ${type} found`)
103
+
104
+            this.$store.commit('SET_HERO', this._setHeroInfo(page))
105
+        },
91
     },
106
     },
92
 }
107
 }
93
 </script>
108
 </script>

Loading…
Откажи
Сачувај