|
|
@@ -1,11 +1,11 @@
|
|
1
|
1
|
<template lang="pug">
|
|
2
|
|
-.page--single.f-row.between
|
|
3
|
|
- gallery(:fullscreengallery="fullscreengallery" v-on:close="fullscreengallery = false")
|
|
|
2
|
+.page--single.f-row.between(v-if="$route.params.slug")
|
|
|
3
|
+ gallery(v-if="images.length" :fullscreengallery="fullscreengallery" v-on:close="fullscreengallery = false" :images="images")
|
|
4
|
4
|
article.f-grow.shadow
|
|
5
|
5
|
header
|
|
6
|
6
|
h1 {{ type }}:{{ $route.params.slug }} single
|
|
7
|
7
|
button(@click="fullscreengallery = true") fullscreen
|
|
8
|
|
- section
|
|
|
8
|
+ section(v-if="posts[$route.params.slug]")
|
|
9
|
9
|
h4 {{ posts[$route.params.slug].title }}
|
|
10
|
10
|
.block-wrapper(v-for="block in posts[$route.params.slug].blocks" v-html="block")
|
|
11
|
11
|
sidebar(v-if="sidebar" :type="`${type}`")
|
|
|
@@ -32,6 +32,7 @@ export default {
|
|
32
|
32
|
},
|
|
33
|
33
|
data() {
|
|
34
|
34
|
return {
|
|
|
35
|
+ images: [],
|
|
35
|
36
|
fullscreengallery: false
|
|
36
|
37
|
}
|
|
37
|
38
|
},
|
|
|
@@ -62,11 +63,36 @@ export default {
|
|
62
|
63
|
}, {})
|
|
63
|
64
|
},
|
|
64
|
65
|
},
|
|
|
66
|
+ methods: {
|
|
|
67
|
+ checkForImages(post) {
|
|
|
68
|
+ const allBlocks = post[this.$route.params.slug].blocks.map(block => {
|
|
|
69
|
+ if(block) return block
|
|
|
70
|
+ })
|
|
|
71
|
+ allBlocks.forEach(block => {
|
|
|
72
|
+ if(!block) return
|
|
|
73
|
+
|
|
|
74
|
+ const domparser = new DOMParser()
|
|
|
75
|
+ const doc = domparser.parseFromString(block, 'text/html')
|
|
|
76
|
+
|
|
|
77
|
+ const gallery = doc.querySelectorAll('.blocks-gallery-item img')
|
|
|
78
|
+ if(gallery) {
|
|
|
79
|
+ this.images = [].slice.call(gallery).map(item => { return item.src })
|
|
|
80
|
+ }
|
|
|
81
|
+ })
|
|
|
82
|
+ }
|
|
|
83
|
+ },
|
|
|
84
|
+ watch: {
|
|
|
85
|
+ posts(newVal, oldVal) {
|
|
|
86
|
+ this.checkForImages(newVal)
|
|
|
87
|
+ }
|
|
|
88
|
+ },
|
|
65
|
89
|
mounted() {
|
|
66
|
90
|
// TODO: this should be conditional after checking vuex state
|
|
67
|
91
|
let type = this.$route.params.type
|
|
68
|
92
|
type = type.charAt(0).toUpperCase() + type.slice(1)
|
|
69
|
93
|
this.$store.dispatch(`getAll${type}`)
|
|
|
94
|
+
|
|
|
95
|
+ console.log(this.images)
|
|
70
|
96
|
}
|
|
71
|
97
|
}
|
|
72
|
98
|
</script>
|