|
|
@@ -74,11 +74,12 @@ export default {
|
|
74
|
74
|
* Careful with name collisions with vuex helpers
|
|
75
|
75
|
*/
|
|
76
|
76
|
singlePost() {
|
|
77
|
|
- if (!this[this.type]) return
|
|
|
77
|
+ const postType = this.type == 'blog' ? 'post': this.type
|
|
|
78
|
+ if (!this[postType]) return
|
|
78
|
79
|
|
|
79
|
80
|
// State not a getter!
|
|
80
|
81
|
const singleOfTypeFromState =
|
|
81
|
|
- this[this.type][`single${convertTitleCase(this.type)}`]
|
|
|
82
|
+ this[postType][`single${convertTitleCase(postType)}`]
|
|
82
|
83
|
|
|
83
|
84
|
if (!singleOfTypeFromState) return
|
|
84
|
85
|
|
|
|
@@ -181,8 +182,9 @@ export default {
|
|
181
|
182
|
* which is derived from the route
|
|
182
|
183
|
*/
|
|
183
|
184
|
// modules are NOT plural because module key
|
|
184
|
|
- if (!this.$store.state[this.type]) return
|
|
185
|
|
- const allPostsOfTypeInStore = this.$store.state[this.type].all
|
|
|
185
|
+ const postType = this.type == 'blog' ? 'post': this.type
|
|
|
186
|
+ if (!this.$store.state[postType]) return
|
|
|
187
|
+ const allPostsOfTypeInStore = this.$store.state[postType].all
|
|
186
|
188
|
|
|
187
|
189
|
/**
|
|
188
|
190
|
* Load posts if they're not already in state
|
|
|
@@ -197,7 +199,7 @@ export default {
|
|
197
|
199
|
if (!singlePostData) {
|
|
198
|
200
|
console.warn('Could not find single post in store; Fetching everything...')
|
|
199
|
201
|
const res = await this.$store.dispatch(
|
|
200
|
|
- `getAll${convertTitleCase(this.type)}s`,
|
|
|
202
|
+ `getAll${convertTitleCase(postType)}s`,
|
|
201
|
203
|
{ sortType: null, params: null }
|
|
202
|
204
|
)
|
|
203
|
205
|
singlePostData = res.filter(
|
|
|
@@ -211,7 +213,7 @@ export default {
|
|
211
|
213
|
try {
|
|
212
|
214
|
this.checkAndSetHero(singlePostData)
|
|
213
|
215
|
await this.$store.dispatch(
|
|
214
|
|
- `getSingle${convertTitleCase(this.type)}`,
|
|
|
216
|
+ `getSingle${convertTitleCase(postType)}`,
|
|
215
|
217
|
singlePostData.id,
|
|
216
|
218
|
)
|
|
217
|
219
|
} catch (err) {
|