|
|
@@ -166,6 +166,7 @@ export default {
|
|
166
|
166
|
*/
|
|
167
|
167
|
checkAndSetHero(post) {
|
|
168
|
168
|
if (!post) return
|
|
|
169
|
+ console.log('single hero...')
|
|
169
|
170
|
let json = { url: post.featured, heroType: 'image' }
|
|
170
|
171
|
if (
|
|
171
|
172
|
post.hero &&
|
|
|
@@ -209,21 +210,22 @@ export default {
|
|
209
|
210
|
// Find the single post from api if it's not already in state
|
|
210
|
211
|
// Then add it to our list
|
|
211
|
212
|
|
|
212
|
|
- // if (!this[`all${type}Loaded`] && allPostsOfType.length < 1) {
|
|
213
|
213
|
const res = await this.$store.dispatch(`getAll${type}`, { sortType: null, params: null})
|
|
214
|
214
|
allPostsOfType = res
|
|
215
|
|
- console.log(`reloaded ${type}...`)
|
|
216
|
|
- // }
|
|
217
|
215
|
|
|
218
|
216
|
const singlePostData = allPostsOfType.filter(
|
|
219
|
217
|
post => post.slug == this.$route.params.slug,
|
|
220
|
218
|
)[0]
|
|
|
219
|
+
|
|
221
|
220
|
if (!singlePostData) return
|
|
|
221
|
+
|
|
222
|
222
|
// NOT plural
|
|
223
|
|
- await this.$store.dispatch(
|
|
|
223
|
+ const post = await this.$store.dispatch(
|
|
224
|
224
|
`getSingle${convertTitleCase(this.type)}`,
|
|
225
|
225
|
singlePostData.id,
|
|
226
|
226
|
)
|
|
|
227
|
+
|
|
|
228
|
+ this.checkAndSetHero(this.singlePost)
|
|
227
|
229
|
},
|
|
228
|
230
|
|
|
229
|
231
|
scrollTo(hashtag) {
|
|
|
@@ -236,9 +238,9 @@ export default {
|
|
236
|
238
|
post(newVal, oldVal) {
|
|
237
|
239
|
// Prevent loading single post when
|
|
238
|
240
|
// navigating AWAY from the page
|
|
239
|
|
- if (!oldVal) {
|
|
240
|
|
- this.checkAndSetHero(newVal)
|
|
241
|
|
- }
|
|
|
241
|
+ // if (!oldVal) {
|
|
|
242
|
+ // this.checkAndSetHero(newVal)
|
|
|
243
|
+ // }
|
|
242
|
244
|
},
|
|
243
|
245
|
$route(to, from) {
|
|
244
|
246
|
// Only load post data when
|
|
|
@@ -253,9 +255,8 @@ export default {
|
|
253
|
255
|
// setTimeout(() => this.scrollTo(this.$route.hash), TIMEOUT)
|
|
254
|
256
|
// }
|
|
255
|
257
|
},
|
|
256
|
|
- async created() {
|
|
257
|
|
- await this.loadPostData()
|
|
258
|
|
- this.checkAndSetHero(this.singlePost)
|
|
|
258
|
+ created() {
|
|
|
259
|
+ this.loadPostData()
|
|
259
|
260
|
},
|
|
260
|
261
|
}
|
|
261
|
262
|
</script>
|