|
|
@@ -84,11 +84,21 @@ export default {
|
|
84
|
84
|
methods: {
|
|
85
|
85
|
async checkAndSetHero(type) {
|
|
86
|
86
|
if (!this['allPagesLoaded']) {
|
|
87
|
|
- await this.$store.dispatch('getAllPages')
|
|
|
87
|
+ await this.$store.dispatch('getAllPages', { sortType: null, params: null })
|
|
88
|
88
|
}
|
|
89
|
|
- const page = this.allPages[type]
|
|
90
|
|
- if (!page) return
|
|
91
|
|
- let json = { url: page.featured, heroType: 'image' }
|
|
|
89
|
+ // We always set a hero no matter what
|
|
|
90
|
+ // Because the hero component will deal
|
|
|
91
|
+ // with how to render based on hero.url
|
|
|
92
|
+ const page = this.allPages.filter(
|
|
|
93
|
+ page => page.slug == type + 's',
|
|
|
94
|
+ )[0]
|
|
|
95
|
+ let hero = { url: null, heroType: null }
|
|
|
96
|
+
|
|
|
97
|
+ // Clear the hero and bail
|
|
|
98
|
+ if(!page) return this.$store.commit('SET_HERO', hero)
|
|
|
99
|
+
|
|
|
100
|
+ hero.url = page.featured
|
|
|
101
|
+ hero.heroType = 'image'
|
|
92
|
102
|
if (
|
|
93
|
103
|
page.hero &&
|
|
94
|
104
|
JSON.parse(page.hero) &&
|
|
|
@@ -97,7 +107,13 @@ export default {
|
|
97
|
107
|
json = JSON.parse(page.hero)
|
|
98
|
108
|
json.heroType = 'video'
|
|
99
|
109
|
}
|
|
100
|
|
- this.$store.commit('SET_HERO', json)
|
|
|
110
|
+ // No featured or youTube
|
|
|
111
|
+ if (!hero.url) {
|
|
|
112
|
+ hero.heroType = null
|
|
|
113
|
+ }
|
|
|
114
|
+ // Set the hero text to the post title or excerpt
|
|
|
115
|
+ hero.text = page && page.excerpt ? page.excerpt : page.title
|
|
|
116
|
+ this.$store.commit('SET_HERO', hero)
|
|
101
|
117
|
},
|
|
102
|
118
|
firstPostOfType(type) {
|
|
103
|
119
|
return Object.values(this[`all${convertTitleCase(type)}s`])[0]
|