Просмотр исходного кода

:sparkles: adding hero to welcome

tags/0.9.0
J 4 лет назад
Родитель
Сommit
fae623070e
1 измененных файлов: 17 добавлений и 2 удалений
  1. 17
    2
      vue-theme/src/pages/index.vue

+ 17
- 2
vue-theme/src/pages/index.vue Просмотреть файл

@@ -33,13 +33,13 @@
33 33
 </template>
34 34
 
35 35
 <script>
36
-import { postTypeGetters, scrollTop } from './mixin-post-types'
36
+import { postTypeGetters, scrollTop, heroUtils } from './mixin-post-types'
37 37
 import card from '@/components/card.vue'
38 38
 
39 39
 import { convertTitleCase, postTypes, sortTypes } from '@/utils/helpers'
40 40
 
41 41
 export default {
42
-    mixins: [postTypeGetters, scrollTop],
42
+    mixins: [postTypeGetters, scrollTop, heroUtils],
43 43
     components: { card },
44 44
     data() {
45 45
         return {
@@ -82,12 +82,27 @@ export default {
82 82
         if (!this['allPagesLoaded']) {
83 83
             await this.$store.dispatch('getAllPages', { sortType: null, params: null })
84 84
         }
85
+        await this.checkAndSetHero('welcome')
85 86
         await this.$store.dispatch('getRandomPosts', ['episode', 'exhibition', 'event', 'artist', 'post'])
86 87
     },
87 88
     methods: {
88 89
         firstPostOfType(type) {
89 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 108
 </script>

Загрузка…
Отмена
Сохранить