|
|
@@ -7,18 +7,18 @@
|
|
7
|
7
|
|
|
8
|
8
|
.post-single.block-wrapper(v-for="(block, i) in post.blocks" :key="`block-${i}`")
|
|
9
|
9
|
//- ?: are objects are always gallery blocks
|
|
10
|
|
- .gallery.block(v-if="typeof block === 'object'")
|
|
|
10
|
+ .gallery.block(v-if="typeof block === 'object'" :class="`gallery-${i}`")
|
|
11
|
11
|
p gallery number: {{ i }}
|
|
12
|
12
|
ul
|
|
13
|
|
- li(v-for="(imageID, j) in post.galleries[block.gallery].ids")
|
|
14
|
|
- button(@click="openGallery(i - 1, j)") gallery: {{ i }} image: {{ imageID }}
|
|
|
13
|
+ li(v-for="(imageID, j) in post.galleries[block.gallery].ids" :class="`gallery-${i}--image-${j+1}`" :key="`block-${i}-${j}`")
|
|
|
14
|
+ img(@click="openGallery(i - 1, imageID)" :src="post.attached[imageID]['thumbnail']")
|
|
|
15
|
+ button(@click="openGallery(i - 1, imageID)") gallery: {{ i }} image: {{ imageID }}
|
|
15
|
16
|
//- Fullscreen gallery
|
|
16
|
17
|
gallery(
|
|
17
|
18
|
v-if="activeGalleryIndex == (i - 1)"
|
|
18
|
|
- :image-ids="post.galleries[block.gallery].ids"
|
|
19
|
19
|
:activeImageIndex="activeImageIndex"
|
|
20
|
20
|
v-on:close="activeGalleryIndex = -1"
|
|
21
|
|
- :image-sizes="post.attached"
|
|
|
21
|
+ :images="imagesInGallery"
|
|
22
|
22
|
)
|
|
23
|
23
|
|
|
24
|
24
|
//- Just a regular block
|
|
|
@@ -49,7 +49,7 @@ export default {
|
|
49
|
49
|
return {
|
|
50
|
50
|
images: [],
|
|
51
|
51
|
activeGalleryIndex: -1,
|
|
52
|
|
- activeImageIndex: -1
|
|
|
52
|
+ activeImageID: -1
|
|
53
|
53
|
}
|
|
54
|
54
|
},
|
|
55
|
55
|
computed: {
|
|
|
@@ -82,13 +82,23 @@ export default {
|
|
82
|
82
|
postsMap[post.slug] = post
|
|
83
|
83
|
return postsMap
|
|
84
|
84
|
}, {})
|
|
|
85
|
+ },
|
|
|
86
|
+ imagesInGallery() {
|
|
|
87
|
+ if(!this.activeGalleryIndex < 0) return {}
|
|
|
88
|
+
|
|
|
89
|
+ return this.post.galleries[this.activeGalleryIndex].ids.reduce((imageMap, id) => {
|
|
|
90
|
+ imageMap[id] = this.post.attached[id]
|
|
|
91
|
+ return imageMap
|
|
|
92
|
+ }, {})
|
|
|
93
|
+ },
|
|
|
94
|
+ activeImageIndex() {
|
|
|
95
|
+ return Object.keys(this.imagesInGallery).indexOf(this.activeImageID.toString())
|
|
85
|
96
|
}
|
|
86
|
97
|
},
|
|
87
|
98
|
methods: {
|
|
88
|
99
|
openGallery(galleryIndex, imageID) {
|
|
89
|
100
|
this.activeGalleryIndex = galleryIndex
|
|
90
|
|
- this.activeImageIndex = imageID ? imageID : 0
|
|
91
|
|
- // console.log(this.post.galleries[galleryIndex])
|
|
|
101
|
+ this.activeImageID = imageID ? imageID : 0
|
|
92
|
102
|
},
|
|
93
|
103
|
checkAndSetHero(posts) {
|
|
94
|
104
|
const post = posts[this.$route.params.slug]
|
|
|
@@ -96,14 +106,6 @@ export default {
|
|
96
|
106
|
|
|
97
|
107
|
const json = JSON.parse(post.hero)
|
|
98
|
108
|
this.$store.commit('SET_HERO', json)
|
|
99
|
|
- },
|
|
100
|
|
- async checkAndSetImages(posts) {
|
|
101
|
|
- const post = posts[this.$route.params.slug]
|
|
102
|
|
- if(!post || ! post.attached) return
|
|
103
|
|
-
|
|
104
|
|
- const imagesAttached = post.attached
|
|
105
|
|
- await this.$store.dispatch(`getMediaById`, imagesAttached)
|
|
106
|
|
- console.log(this.$store.media)
|
|
107
|
109
|
}
|
|
108
|
110
|
},
|
|
109
|
111
|
watch: {
|
|
|
@@ -112,7 +114,6 @@ export default {
|
|
112
|
114
|
// this.checkForImages(newVal)
|
|
113
|
115
|
|
|
114
|
116
|
this.checkAndSetHero(newVal)
|
|
115
|
|
- this.checkAndSetImages(newVal)
|
|
116
|
117
|
}
|
|
117
|
118
|
},
|
|
118
|
119
|
created() {
|