|
|
@@ -8,6 +8,7 @@
|
|
8
|
8
|
h1 {{ type }}:{{ $route.params.slug }} {{ post.title }}
|
|
9
|
9
|
p(v-if="post.categories") categories: {{ post.categories }}
|
|
10
|
10
|
p(v-if="post.type") type: {{ post.type }}
|
|
|
11
|
+ p(v-if="post.subtypes") subtypes: {{ post.subtypes }}
|
|
11
|
12
|
|
|
12
|
13
|
.date-info(v-if="type === 'events' || post.type === 'exhibitions'")
|
|
13
|
14
|
p start: {{ dateFrom(post.start) }}
|
|
|
@@ -17,11 +18,13 @@
|
|
17
|
18
|
|
|
18
|
19
|
credits(v-if="type === 'episodes'" :post="post")
|
|
19
|
20
|
|
|
20
|
|
- sidebar(v-if="sidebar" :type="`${type}`")
|
|
21
|
|
- .shadow
|
|
22
|
|
- h1.t-up single slot
|
|
23
|
|
- div
|
|
24
|
|
- p body whatever
|
|
|
21
|
+ sidebar(v-if="sidebar" :type="`${type}`" layout="single")
|
|
|
22
|
+ .shadow(v-if="Object.keys(p2pPostsByType).length" v-for="p2pPostType in Object.keys(p2pPostsByType)")
|
|
|
23
|
+ h3.t-up related {{ p2pPostType }}s
|
|
|
24
|
+ ul
|
|
|
25
|
+ li(v-for="relatedPost in p2pPostsByType[p2pPostType]")
|
|
|
26
|
+ router-link(v-if="relatedPost" :to="`/${relatedPost.type}s/${relatedPost.slug}`")
|
|
|
27
|
+ p {{ relatedPost.title }}
|
|
25
|
28
|
</template>
|
|
26
|
29
|
|
|
27
|
30
|
<script>
|
|
|
@@ -90,6 +93,13 @@ export default {
|
|
90
|
93
|
},
|
|
91
|
94
|
activeImageIndex() {
|
|
92
|
95
|
return Object.keys(this.imagesInGallery).indexOf(this.activeImageID.toString())
|
|
|
96
|
+ },
|
|
|
97
|
+ p2pPostsByType() {
|
|
|
98
|
+ return this.post ? Object.values(this.post.relatedto).reduce((byType, relatedPost) => {
|
|
|
99
|
+ if(!byType[relatedPost.type]) byType[relatedPost.type] = []
|
|
|
100
|
+ byType[relatedPost.type].push(relatedPost)
|
|
|
101
|
+ return byType
|
|
|
102
|
+ }, {}) : {}
|
|
93
|
103
|
}
|
|
94
|
104
|
},
|
|
95
|
105
|
methods: {
|
|
|
@@ -129,32 +139,41 @@ export default {
|
|
129
|
139
|
dateFrom(unix) {
|
|
130
|
140
|
return new Date( parseInt(unix) * 1000 )
|
|
131
|
141
|
},
|
|
|
142
|
+
|
|
|
143
|
+ async loadPostData() {
|
|
|
144
|
+ /**
|
|
|
145
|
+ * Conditionally load based on post type
|
|
|
146
|
+ * which is derived from the route
|
|
|
147
|
+ * !: posts watcher fires when this finishes
|
|
|
148
|
+ */
|
|
|
149
|
+ let type = convertTitleCase(this.type)
|
|
|
150
|
+ let allPostsOfType = this.$store.state[this.type].all
|
|
|
151
|
+
|
|
|
152
|
+ /**
|
|
|
153
|
+ * Load posts if they're not already in state
|
|
|
154
|
+ */
|
|
|
155
|
+ if(!this[`all${type}Loaded`] && allPostsOfType.length < 1) {
|
|
|
156
|
+ const res = await this.$store.dispatch(`getAll${type}`)
|
|
|
157
|
+ allPostsOfType = res
|
|
|
158
|
+ console.log(`reloaded ${type}...`)
|
|
|
159
|
+ }
|
|
|
160
|
+ const singlePostData = Object.values(allPostsOfType).filter(post => post.slug == this.$route.params.slug)[0]
|
|
|
161
|
+
|
|
|
162
|
+ if(!singlePostData) return
|
|
|
163
|
+ await this.$store.dispatch(`getSingle${dePluralize(type)}`, singlePostData.id)
|
|
|
164
|
+ }
|
|
132
|
165
|
},
|
|
133
|
166
|
watch: {
|
|
134
|
167
|
post(newVal, oldVal) {
|
|
135
|
168
|
this.checkAndSetHero(newVal)
|
|
|
169
|
+ },
|
|
|
170
|
+ $route(newVal, oldVal) {
|
|
|
171
|
+ console.log('route changed...')
|
|
|
172
|
+ this.loadPostData()
|
|
136
|
173
|
}
|
|
137
|
174
|
},
|
|
138
|
175
|
async created() {
|
|
139
|
|
- /**
|
|
140
|
|
- * Conditionally load based on post type
|
|
141
|
|
- * which is derived from the route
|
|
142
|
|
- * !: posts watcher fires when this finishes
|
|
143
|
|
- */
|
|
144
|
|
- let type = convertTitleCase(this.type)
|
|
145
|
|
- let allPostsOfType = this.$store.state[this.type].all
|
|
146
|
|
-
|
|
147
|
|
- /**
|
|
148
|
|
- * Load posts if they're not already in state
|
|
149
|
|
- */
|
|
150
|
|
- if(!this[`all${type}Loaded`] && allPostsOfType.length < 1) {
|
|
151
|
|
- const res = await this.$store.dispatch(`getAll${type}`)
|
|
152
|
|
- allPostsOfType = res
|
|
153
|
|
- console.log(`reloaded ${type}...`)
|
|
154
|
|
- }
|
|
155
|
|
- const singlePostData = Object.values(allPostsOfType).filter(post => post.slug == this.$route.params.slug)[0]
|
|
156
|
|
-
|
|
157
|
|
- await this.$store.dispatch(`getSingle${dePluralize(type)}`, singlePostData.id)
|
|
|
176
|
+ this.loadPostData()
|
|
158
|
177
|
}
|
|
159
|
178
|
}
|
|
160
|
179
|
</script>
|