|
|
@@ -61,8 +61,10 @@ export default {
|
|
61
|
61
|
return this.$route.params.type ? this.$route.params.type : this.$route.fullPath.slice(1)
|
|
62
|
62
|
},
|
|
63
|
63
|
posts() {
|
|
64
|
|
- let type = this.type.charAt(0).toUpperCase() + this.type.slice(1)
|
|
65
|
|
-
|
|
|
64
|
+ let type = this.convertTitleCase(this.type)
|
|
|
65
|
+
|
|
|
66
|
+ if(!type) return []
|
|
|
67
|
+
|
|
66
|
68
|
// Return list keyed by slug
|
|
67
|
69
|
return Object.values(this[`all${type}`]).reduce((postsMap, post) => {
|
|
68
|
70
|
postsMap[post.slug] = post
|
|
|
@@ -71,6 +73,9 @@ export default {
|
|
71
|
73
|
}
|
|
72
|
74
|
},
|
|
73
|
75
|
methods: {
|
|
|
76
|
+ convertTitleCase(type) {
|
|
|
77
|
+ return type.charAt(0).toUpperCase() + type.slice(1)
|
|
|
78
|
+ },
|
|
74
|
79
|
pageBlocks(posts) {
|
|
75
|
80
|
if(this.images.length < 1) return []
|
|
76
|
81
|
return posts[this.$route.params.slug].blocks.map(block => {
|
|
|
@@ -128,9 +133,8 @@ export default {
|
|
128
|
133
|
},
|
|
129
|
134
|
created() {
|
|
130
|
135
|
if(!this.allLoaded) {
|
|
131
|
|
- let type = this.$route.params.type
|
|
132
|
|
- type = type.charAt(0).toUpperCase() + type.slice(1)
|
|
133
|
|
- console.log('retrieving...', type)
|
|
|
136
|
+ let type = this.convertTitleCase(this.$route.params.type)
|
|
|
137
|
+ console.log('Retrieving...', type)
|
|
134
|
138
|
this.$store.dispatch(`getAll${type}`)
|
|
135
|
139
|
}
|
|
136
|
140
|
}
|