|
|
@@ -81,12 +81,7 @@ export default {
|
|
81
|
81
|
},
|
|
82
|
82
|
},
|
|
83
|
83
|
methods: {
|
|
84
|
|
- getThumbnailFromYt(url) {
|
|
85
|
|
- return ytThumbnail(url, 'medium')
|
|
86
|
|
- },
|
|
87
|
84
|
setHeroAndGetPosts() {
|
|
88
|
|
- let type = convertTitleCase(this.type)
|
|
89
|
|
-
|
|
90
|
85
|
// Sorting
|
|
91
|
86
|
let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
|
|
92
|
87
|
|
|
|
@@ -100,26 +95,35 @@ export default {
|
|
100
|
95
|
// Don't dispatch if there's no type
|
|
101
|
96
|
if(this.type) {
|
|
102
|
97
|
this.$store.dispatch(this.dispatchName, sort)
|
|
|
98
|
+ this.checkAndSetHero()
|
|
103
|
99
|
}
|
|
104
|
|
-
|
|
105
|
|
- if(this.$store.state.hero.url !== type) this.$store.commit('SET_HERO', type)
|
|
106
|
|
- }
|
|
|
100
|
+ },
|
|
|
101
|
+ checkAndSetHero() {
|
|
|
102
|
+ const page = this.allPages[this.type]
|
|
|
103
|
+ if(!page) return
|
|
|
104
|
+ let json = { url: page.featured, heroType: 'image' }
|
|
|
105
|
+ if(page.hero && JSON.parse(page.hero).url) {
|
|
|
106
|
+ json = JSON.parse(page.hero)
|
|
|
107
|
+ json.heroType = 'video'
|
|
|
108
|
+ }
|
|
|
109
|
+ this.$store.commit('SET_HERO', json)
|
|
|
110
|
+ },
|
|
107
|
111
|
},
|
|
108
|
112
|
watch: {
|
|
109
|
|
- $route(to, from){
|
|
|
113
|
+ async $route(to, from){
|
|
110
|
114
|
// console.log(this.sidebar)
|
|
111
|
115
|
let type = convertTitleCase(this.type)
|
|
112
|
116
|
let sort = this.sortBy ? this.sortBy : to.path.split('/').pop()
|
|
113
|
117
|
|
|
114
|
|
- this.$store.dispatch('getAllPages')
|
|
115
|
|
- if(!this[`all${type}Loaded`] || sort) this.setHeroAndGetPosts()
|
|
|
118
|
+ await this.$store.dispatch('getAllPages')
|
|
|
119
|
+ if(!this[`all${type}Loaded`] && this['allPagesLoaded'] || sort) this.setHeroAndGetPosts()
|
|
116
|
120
|
}
|
|
117
|
121
|
},
|
|
118
|
|
- created() {
|
|
|
122
|
+ async created() {
|
|
119
|
123
|
let type = convertTitleCase(this.type)
|
|
120
|
124
|
// console.log('already loaded ?:', this[`all${type}Loaded`])
|
|
121
|
|
- this.$store.dispatch('getAllPages')
|
|
122
|
|
- if(!this[`all${type}Loaded`]) this.setHeroAndGetPosts()
|
|
|
125
|
+ await this.$store.dispatch('getAllPages')
|
|
|
126
|
+ if(!this[`all${type}Loaded`] && this['allPagesLoaded']) this.setHeroAndGetPosts()
|
|
123
|
127
|
}
|
|
124
|
128
|
}
|
|
125
|
129
|
</script>
|