|
|
@@ -48,43 +48,47 @@ import breadcrumb from '@/components/breadcrumb'
|
|
48
|
48
|
import { postTypeGetters, scrollTop } from './mixin-post-types'
|
|
49
|
49
|
|
|
50
|
50
|
import { convertTitleCase, dePluralize, typeFromRoute } from '@/utils/helpers'
|
|
51
|
|
-
|
|
|
51
|
+
|
|
|
52
|
+const TIMEOUT = 1
|
|
|
53
|
+
|
|
52
|
54
|
export default {
|
|
53
|
55
|
components: { sidebar, gallery, credits, card, breadcrumb },
|
|
54
|
56
|
props: {
|
|
55
|
57
|
sidebar: { type: Boolean },
|
|
56
|
|
- id: { type: Number }
|
|
|
58
|
+ id: { type: Number },
|
|
57
|
59
|
},
|
|
58
|
60
|
mixins: [postTypeGetters, scrollTop],
|
|
59
|
61
|
data() {
|
|
60
|
62
|
return {
|
|
61
|
63
|
// Gallery control
|
|
62
|
64
|
activeGalleryIndex: -1,
|
|
63
|
|
- activeImageID: -1
|
|
|
65
|
+ activeImageID: -1,
|
|
64
|
66
|
}
|
|
65
|
67
|
},
|
|
66
|
68
|
computed: {
|
|
67
|
|
- type() { // Checks for type and fixes Episodes route edge case
|
|
|
69
|
+ type() {
|
|
|
70
|
+ // Checks for type and fixes Episodes route edge case
|
|
68
|
71
|
return typeFromRoute(this.$route)
|
|
69
|
72
|
},
|
|
70
|
73
|
/**
|
|
71
|
74
|
* We get the actual post data using the slug
|
|
72
|
75
|
*/
|
|
73
|
76
|
post() {
|
|
74
|
|
- if(!this[this.type]) return
|
|
|
77
|
+ if (!this[this.type]) return
|
|
75
|
78
|
|
|
76
|
79
|
const type = dePluralize(this.type)
|
|
77
|
80
|
|
|
78
|
81
|
// State not a getter!
|
|
79
|
|
- const singleOfTypeFromState = this[this.type][`single${convertTitleCase(type)}`]
|
|
|
82
|
+ const singleOfTypeFromState =
|
|
|
83
|
+ this[this.type][`single${convertTitleCase(type)}`]
|
|
80
|
84
|
|
|
81
|
|
- if(!singleOfTypeFromState) return
|
|
|
85
|
+ if (!singleOfTypeFromState) return
|
|
82
|
86
|
|
|
83
|
87
|
return singleOfTypeFromState
|
|
84
|
88
|
},
|
|
85
|
89
|
|
|
86
|
90
|
idsForGallery() {
|
|
87
|
|
- if(!this.post || this.activeGalleryIndex < 0) return []
|
|
|
91
|
+ if (!this.post || this.activeGalleryIndex < 0) return []
|
|
88
|
92
|
return this.post.galleries[this.activeGalleryIndex].ids
|
|
89
|
93
|
},
|
|
90
|
94
|
/**
|
|
|
@@ -94,7 +98,7 @@ export default {
|
|
94
|
98
|
* image size and url information returned by post.attached
|
|
95
|
99
|
*/
|
|
96
|
100
|
imagesInGallery() {
|
|
97
|
|
- if(!this.activeGalleryIndex < 0) return {}
|
|
|
101
|
+ if (!this.activeGalleryIndex < 0) return {}
|
|
98
|
102
|
|
|
99
|
103
|
return this.idsForGallery.reduce((imageMap, id) => {
|
|
100
|
104
|
imageMap[id] = this.post.attached[parseInt(id)]
|
|
|
@@ -102,15 +106,23 @@ export default {
|
|
102
|
106
|
}, {})
|
|
103
|
107
|
},
|
|
104
|
108
|
activeImageIndex() {
|
|
105
|
|
- return Object.keys(this.imagesInGallery).indexOf(this.activeImageID.toString())
|
|
|
109
|
+ return Object.keys(this.imagesInGallery).indexOf(
|
|
|
110
|
+ this.activeImageID.toString(),
|
|
|
111
|
+ )
|
|
106
|
112
|
},
|
|
107
|
113
|
p2pPostsByType() {
|
|
108
|
|
- return this.post ? Object.values(this.post.relatedto).reduce((byType, relatedPost) => {
|
|
109
|
|
- if(!byType[relatedPost.type]) byType[relatedPost.type] = []
|
|
110
|
|
- byType[relatedPost.type].push(relatedPost)
|
|
111
|
|
- return byType
|
|
112
|
|
- }, {}) : {}
|
|
113
|
|
- }
|
|
|
114
|
+ return this.post
|
|
|
115
|
+ ? Object.values(this.post.relatedto).reduce(
|
|
|
116
|
+ (byType, relatedPost) => {
|
|
|
117
|
+ if (!byType[relatedPost.type])
|
|
|
118
|
+ byType[relatedPost.type] = []
|
|
|
119
|
+ byType[relatedPost.type].push(relatedPost)
|
|
|
120
|
+ return byType
|
|
|
121
|
+ },
|
|
|
122
|
+ {},
|
|
|
123
|
+ )
|
|
|
124
|
+ : {}
|
|
|
125
|
+ },
|
|
114
|
126
|
},
|
|
115
|
127
|
methods: {
|
|
116
|
128
|
/**
|
|
|
@@ -121,16 +133,26 @@ export default {
|
|
121
|
133
|
* @param {string} imageInfo
|
|
122
|
134
|
*/
|
|
123
|
135
|
openGallery(imageInfo) {
|
|
124
|
|
- const byIndex = this.post.galleries.reduce((byIndex, gallery, index) => {
|
|
125
|
|
- byIndex[index] = gallery.ids
|
|
126
|
|
- return byIndex
|
|
127
|
|
- }, {})
|
|
|
136
|
+ const byIndex = this.post.galleries.reduce(
|
|
|
137
|
+ (byIndex, gallery, index) => {
|
|
|
138
|
+ byIndex[index] = gallery.ids
|
|
|
139
|
+ return byIndex
|
|
|
140
|
+ },
|
|
|
141
|
+ {},
|
|
|
142
|
+ )
|
|
128
|
143
|
let matchingIndex = 0
|
|
129
|
144
|
Object.keys(byIndex).forEach(galleryIndex => {
|
|
130
|
|
- if(byIndex[galleryIndex].includes(parseInt(imageInfo.dataset.id))) matchingIndex = galleryIndex
|
|
|
145
|
+ if (
|
|
|
146
|
+ byIndex[galleryIndex].includes(
|
|
|
147
|
+ parseInt(imageInfo.dataset.id),
|
|
|
148
|
+ )
|
|
|
149
|
+ )
|
|
|
150
|
+ matchingIndex = galleryIndex
|
|
131
|
151
|
})
|
|
132
|
152
|
this.activeGalleryIndex = matchingIndex
|
|
133
|
|
- this.activeImageID = imageInfo.dataset.id ? parseInt(imageInfo.dataset.id) : parseInt(imageInfo.className.split('-').pop())
|
|
|
153
|
+ this.activeImageID = imageInfo.dataset.id
|
|
|
154
|
+ ? parseInt(imageInfo.dataset.id)
|
|
|
155
|
+ : parseInt(imageInfo.className.split('-').pop())
|
|
134
|
156
|
},
|
|
135
|
157
|
closeGallery() {
|
|
136
|
158
|
this.activeGalleryIndex = this.activeImageID = -1
|
|
|
@@ -142,28 +164,32 @@ export default {
|
|
142
|
164
|
* @param {object} posts
|
|
143
|
165
|
*/
|
|
144
|
166
|
checkAndSetHero(post) {
|
|
145
|
|
- if(!post) return
|
|
|
167
|
+ if (!post) return
|
|
146
|
168
|
|
|
147
|
169
|
let json = { url: post.featured, heroType: 'image' }
|
|
148
|
|
- if(post.hero && JSON.parse(post.hero) && JSON.parse(post.hero).url) {
|
|
|
170
|
+ if (
|
|
|
171
|
+ post.hero &&
|
|
|
172
|
+ JSON.parse(post.hero) &&
|
|
|
173
|
+ JSON.parse(post.hero).url
|
|
|
174
|
+ ) {
|
|
149
|
175
|
json = JSON.parse(post.hero)
|
|
150
|
176
|
json.heroType = 'video'
|
|
151
|
177
|
}
|
|
152
|
178
|
// No featured or youTube
|
|
153
|
|
- if(!json.url) {
|
|
|
179
|
+ if (!json.url) {
|
|
154
|
180
|
json.heroType = null
|
|
155
|
181
|
}
|
|
156
|
182
|
// Set the hero text to the post title
|
|
157
|
183
|
json.text = post.title
|
|
158
|
|
-
|
|
|
184
|
+
|
|
159
|
185
|
this.$store.commit('SET_HERO', json)
|
|
160
|
186
|
},
|
|
161
|
|
-
|
|
|
187
|
+
|
|
162
|
188
|
/**
|
|
163
|
189
|
* Date Object from unix strings from db
|
|
164
|
190
|
*/
|
|
165
|
191
|
dateFrom(unix) {
|
|
166
|
|
- return new Date( parseInt(unix) * 1000 )
|
|
|
192
|
+ return new Date(parseInt(unix) * 1000)
|
|
167
|
193
|
},
|
|
168
|
194
|
|
|
169
|
195
|
async loadPostData() {
|
|
|
@@ -173,27 +199,38 @@ export default {
|
|
173
|
199
|
* !: posts watcher fires when this finishes
|
|
174
|
200
|
*/
|
|
175
|
201
|
let type = convertTitleCase(this.type)
|
|
176
|
|
-
|
|
177
|
|
- if(!this.$store.state[this.type]) return
|
|
|
202
|
+
|
|
|
203
|
+ if (!this.$store.state[this.type]) return
|
|
178
|
204
|
|
|
179
|
205
|
let allPostsOfType = this.$store.state[this.type].all
|
|
180
|
206
|
|
|
181
|
207
|
/**
|
|
182
|
208
|
* Load posts if they're not already in state
|
|
183
|
209
|
*/
|
|
184
|
|
- if(!this[`all${type}Loaded`] && allPostsOfType.length < 1) {
|
|
|
210
|
+ if (!this[`all${type}Loaded`] && allPostsOfType.length < 1) {
|
|
185
|
211
|
const res = await this.$store.dispatch(`getAll${type}`)
|
|
186
|
212
|
allPostsOfType = res
|
|
187
|
213
|
// console.log(`reloaded ${type}...`)
|
|
188
|
214
|
}
|
|
189
|
215
|
|
|
190
|
|
- if(Object.values(allPostsOfType).length < 1) return
|
|
191
|
|
- const singlePostData = Object.values(allPostsOfType).filter(post => post.slug == this.$route.params.slug)[0]
|
|
|
216
|
+ if (Object.values(allPostsOfType).length < 1) return
|
|
|
217
|
+ const singlePostData = Object.values(allPostsOfType).filter(
|
|
|
218
|
+ post => post.slug == this.$route.params.slug,
|
|
|
219
|
+ )[0]
|
|
192
|
220
|
|
|
193
|
|
- if(!singlePostData) return
|
|
|
221
|
+ if (!singlePostData) return
|
|
194
|
222
|
|
|
195
|
|
- await this.$store.dispatch(`getSingle${dePluralize(type)}`, singlePostData.id)
|
|
196
|
|
- }
|
|
|
223
|
+ await this.$store.dispatch(
|
|
|
224
|
+ `getSingle${dePluralize(type)}`,
|
|
|
225
|
+ singlePostData.id,
|
|
|
226
|
+ )
|
|
|
227
|
+ },
|
|
|
228
|
+
|
|
|
229
|
+ scrollTo(hashtag) {
|
|
|
230
|
+ setTimeout(() => {
|
|
|
231
|
+ location.href = hashtag
|
|
|
232
|
+ }, TIMEOUT)
|
|
|
233
|
+ },
|
|
197
|
234
|
},
|
|
198
|
235
|
watch: {
|
|
199
|
236
|
post(newVal, oldVal) {
|
|
|
@@ -201,92 +238,36 @@ export default {
|
|
201
|
238
|
},
|
|
202
|
239
|
$route(newVal, oldVal) {
|
|
203
|
240
|
this.loadPostData()
|
|
|
241
|
+ },
|
|
|
242
|
+ },
|
|
|
243
|
+ mounted() {
|
|
|
244
|
+ if (this.$route.hash) {
|
|
|
245
|
+ setTimeout(() => this.scrollTo(this.$route.hash), TIMEOUT)
|
|
204
|
246
|
}
|
|
205
|
247
|
},
|
|
206
|
248
|
async created() {
|
|
207
|
249
|
await this.loadPostData()
|
|
208
|
250
|
this.checkAndSetHero(this.post)
|
|
209
|
|
- }
|
|
|
251
|
+ },
|
|
210
|
252
|
}
|
|
211
|
253
|
</script>
|
|
212
|
254
|
|
|
213
|
255
|
<style lang="postcss">
|
|
214
|
|
-@import '../sss/variables.sss'
|
|
215
|
|
-@import '../sss/theme.sss'
|
|
216
|
|
-.page--single
|
|
217
|
|
- /* background-color: $cia_white2 */
|
|
218
|
|
- article
|
|
219
|
|
- background-color: white
|
|
220
|
|
- padding: $ms-0
|
|
221
|
|
- h1
|
|
222
|
|
- color: $cia_black
|
|
223
|
|
- /* font-weight: 800 */
|
|
224
|
|
- /* padding: $ms--3 0 */
|
|
225
|
|
- > ul
|
|
226
|
|
- /* grid-gap: $ms-0 */
|
|
227
|
|
- list-style: none
|
|
228
|
|
- /* change to a 1/3 width of the article*/
|
|
229
|
|
- img.feature
|
|
230
|
|
- width: 20em
|
|
231
|
|
- li
|
|
232
|
|
- /* iframe container 16:9 */
|
|
233
|
|
- .iframe-container
|
|
234
|
|
- position: relative
|
|
235
|
|
- width: 100%
|
|
236
|
|
- padding-bottom: 56.25%
|
|
237
|
|
-
|
|
238
|
|
- /* iframe container portrait */
|
|
239
|
|
- .iframe-container-v
|
|
240
|
|
- position: relative
|
|
241
|
|
- width: 100%
|
|
242
|
|
- height: 100%
|
|
243
|
|
- padding-bottom: 125%
|
|
244
|
|
-
|
|
245
|
|
- iframe
|
|
246
|
|
- position: absolute
|
|
247
|
|
- top: 0px
|
|
248
|
|
- left: 0px
|
|
249
|
|
- width: 100%
|
|
250
|
|
- height: 100%
|
|
251
|
|
-
|
|
252
|
|
- .wp-block-embed .is-type-video
|
|
253
|
|
- position: relative
|
|
254
|
|
- width: 100%
|
|
255
|
|
- padding-bottom: 56.25%
|
|
256
|
|
-
|
|
257
|
|
- * hr
|
|
258
|
|
- border: $ms--3
|
|
259
|
|
- margin: $ms-2 auto
|
|
260
|
|
- outline-style: auto
|
|
261
|
|
-
|
|
262
|
|
- &.is-style-default
|
|
263
|
|
- height: 1px
|
|
264
|
|
- width: 15vw
|
|
265
|
|
-
|
|
266
|
|
- &.is-style-wide
|
|
267
|
|
- height: 1px
|
|
268
|
|
- width: 50vw
|
|
269
|
|
-
|
|
270
|
|
- &.is-style-dots
|
|
271
|
|
- outline-style: none
|
|
272
|
|
- font-weight: bolder
|
|
273
|
|
-
|
|
274
|
|
- breadcrumb
|
|
275
|
|
- h5
|
|
276
|
|
- /* color: yellow */
|
|
277
|
|
- color: $cia_red
|
|
278
|
|
- /* font-weight: 400 */
|
|
279
|
|
- /* padding: $ms--6 0 */
|
|
280
|
|
-
|
|
281
|
|
- //- end of article icon
|
|
282
|
|
- footer
|
|
283
|
|
- padding: $ms-6 0
|
|
284
|
|
- img
|
|
285
|
|
- height: $ms-3
|
|
286
|
|
- width: $ms-3
|
|
287
|
|
-
|
|
288
|
|
-
|
|
289
|
|
-@media (min-width: $medium)
|
|
290
|
|
- .page--single.f-col
|
|
291
|
|
- flex-direction: row
|
|
292
|
|
-</style>
|
|
|
256
|
+@import '../sss/variables.sss' @import '../sss/theme.sss' .page--single
|
|
|
257
|
+ /* background-color: $cia_white2 */ article background-color: white padding:
|
|
|
258
|
+ $ms-0 h1 color: $cia_black /* font-weight: 800 */ /* padding: $ms--3 0 */ >
|
|
|
259
|
+ ul /* grid-gap: $ms-0 */ list-style: none
|
|
|
260
|
+ /* change to a 1/3 width of the article*/ img.feature width: 20em li
|
|
|
261
|
+ /* iframe container 16:9 */ .iframe-container position: relative width: 100%
|
|
|
262
|
+ padding-bottom: 56.25% /* iframe container portrait */ .iframe-container-v
|
|
|
263
|
+ position: relative width: 100% height: 100% padding-bottom: 125% iframe
|
|
|
264
|
+ position: absolute top: 0px left: 0px width: 100% height: 100%
|
|
|
265
|
+ .wp-block-embed .is-type-video position: relative width: 100% padding-bottom:
|
|
|
266
|
+ 56.25% * hr border: $ms--3 margin: $ms-2 auto outline-style: auto
|
|
|
267
|
+ &.is-style-default height: 1px width: 15vw &.is-style-wide height: 1px width:
|
|
|
268
|
+ 50vw &.is-style-dots outline-style: none font-weight: bolder breadcrumb h5
|
|
|
269
|
+ /* color: yellow */ color: $cia_red /* font-weight: 400 */
|
|
|
270
|
+ /* padding: $ms--6 0 */ //- end of article icon
|
|
|
271
|
+ footer padding: $ms-6 0 img height: $ms-3 width: $ms-3 @media
|
|
|
272
|
+ (min-width: $medium) .page--single.f-col flex-direction: row;
|
|
|
273
|
+</style>
|