|
|
@@ -1,27 +1,38 @@
|
|
1
|
1
|
<template lang="pug">
|
|
2
|
2
|
.page--single.f-row.between
|
|
3
|
|
- gallery(:fullscreengallery="fullscreengallery" v-on:close="fullscreengallery = -1" :images="images")
|
|
4
|
|
-
|
|
5
|
3
|
article.f-grow.shadow
|
|
6
|
4
|
header
|
|
7
|
5
|
h1 {{ type }}:{{ $route.params.slug }} single
|
|
8
|
|
- p {{galleries}}
|
|
9
|
6
|
p categories:
|
|
10
|
|
- span(v-for="category in posts[$route.params.slug].categories") {{ category }}
|
|
11
|
|
- section(v-if="posts[$route.params.slug]")
|
|
12
|
|
- h4 {{ posts[$route.params.slug].title }}
|
|
13
|
|
- .block-wrapper(v-for="block in posts[$route.params.slug].blocks")
|
|
14
|
|
- .block(v-if="typeof block === 'object'")
|
|
15
|
|
- p gallery {{ block.gallery + 1 }}:
|
|
|
7
|
+ span(v-for="category in post.categories") {{ category }}
|
|
|
8
|
+
|
|
|
9
|
+ section(v-if="post")
|
|
|
10
|
+ h4 {{ post.title }}
|
|
|
11
|
+ p {{ activeGalleryIndex }}
|
|
|
12
|
+ .block-wrapper(v-for="(block, i) in post.blocks")
|
|
|
13
|
+ //- ?: are objects are always gallery blocks
|
|
|
14
|
+ .gallery.block(v-if="typeof block === 'object'")
|
|
|
15
|
+ p gallery number: {{ i }}
|
|
16
|
16
|
ul
|
|
17
|
|
- li(v-for="imageID in posts[$route.params.slug].galleries[block.gallery].ids") image: {{ imageID }}
|
|
|
17
|
+ li(v-for="(imageID, j) in post.galleries[block.gallery].ids")
|
|
|
18
|
+ button(@click="openGallery(i - 1, j)") gallery: {{ i }} image: {{ imageID }}
|
|
|
19
|
+ //- Fullscreen gallery
|
|
|
20
|
+ gallery(
|
|
|
21
|
+ v-if="activeGalleryIndex == (i - 1)"
|
|
|
22
|
+ :activeGalleryIndex="activeGalleryIndex"
|
|
|
23
|
+ :image-ids="post.galleries[block.gallery].ids"
|
|
|
24
|
+ :activeImageIndex="activeImageIndex"
|
|
|
25
|
+ v-on:close="activeGalleryIndex = -1"
|
|
|
26
|
+ )
|
|
|
27
|
+
|
|
|
28
|
+ //- Just a regular block
|
|
18
|
29
|
.block(v-else v-html="block")
|
|
19
|
30
|
|
|
20
|
|
- sidebar(v-if="sidebar" :type="`${type}`")
|
|
21
|
|
- .shadow
|
|
22
|
|
- h1.t-up single slot
|
|
23
|
|
- div
|
|
24
|
|
- p body whatever
|
|
|
31
|
+ //- sidebar(v-if="sidebar" :type="`${type}`")
|
|
|
32
|
+ //- .shadow
|
|
|
33
|
+ //- h1.t-up single slot
|
|
|
34
|
+ //- div
|
|
|
35
|
+ //- p body whatever
|
|
25
|
36
|
</template>
|
|
26
|
37
|
|
|
27
|
38
|
<script>
|
|
|
@@ -41,10 +52,14 @@ export default {
|
|
41
|
52
|
data() {
|
|
42
|
53
|
return {
|
|
43
|
54
|
images: [],
|
|
44
|
|
- fullscreengallery: -1
|
|
|
55
|
+ activeGalleryIndex: -1,
|
|
|
56
|
+ activeImageIndex: -1
|
|
45
|
57
|
}
|
|
46
|
58
|
},
|
|
47
|
59
|
computed: {
|
|
|
60
|
+ post() {
|
|
|
61
|
+ return this.posts[this.$route.params.slug]
|
|
|
62
|
+ },
|
|
48
|
63
|
...mapGetters({
|
|
49
|
64
|
allPages: 'allPages',
|
|
50
|
65
|
allPagesLoaded: 'allPagesLoaded',
|
|
|
@@ -61,10 +76,6 @@ export default {
|
|
61
|
76
|
type() { // Checks for type and fixes Episodes route edge case
|
|
62
|
77
|
return typeFromRoute(this.$route)
|
|
63
|
78
|
},
|
|
64
|
|
- galleries() {
|
|
65
|
|
- if(!this.posts || !this.$route || !this.posts[this.$route.params.slug]) return
|
|
66
|
|
- return this.posts[this.$route.params.slug].galleries[block.gallery].ids
|
|
67
|
|
- },
|
|
68
|
79
|
posts() {
|
|
69
|
80
|
let type = convertTitleCase(this.type)
|
|
70
|
81
|
|
|
|
@@ -78,25 +89,10 @@ export default {
|
|
78
|
89
|
}
|
|
79
|
90
|
},
|
|
80
|
91
|
methods: {
|
|
81
|
|
- pageBlocks(posts) {
|
|
82
|
|
- if(!posts || !posts[this.$route.params.slug] || !posts[this.$route.params.slug].blocks ) return []
|
|
83
|
|
-
|
|
84
|
|
- return posts[this.$route.params.slug].blocks.map(block => {
|
|
85
|
|
- if(block) return block
|
|
86
|
|
- })
|
|
87
|
|
- },
|
|
88
|
|
- checkForImages(posts) {
|
|
89
|
|
- if(Object.keys(posts).length == 0) return
|
|
90
|
|
- this.pageBlocks(posts).forEach(block => {
|
|
91
|
|
- const doc = new DOMParser().parseFromString(block, 'text/html')
|
|
92
|
|
- const gallery = doc.querySelectorAll('.blocks-gallery-item img')
|
|
93
|
|
-
|
|
94
|
|
- if(!gallery || gallery.length < 1) return
|
|
95
|
|
-
|
|
96
|
|
- this.images = [].slice.call(gallery).map(item => {
|
|
97
|
|
- return item.src
|
|
98
|
|
- })
|
|
99
|
|
- })
|
|
|
92
|
+ openGallery(galleryIndex, imageID) {
|
|
|
93
|
+ this.activeGalleryIndex = galleryIndex
|
|
|
94
|
+ this.activeImageIndex = imageID ? imageID : 0
|
|
|
95
|
+ // console.log(this.post.galleries[galleryIndex])
|
|
100
|
96
|
},
|
|
101
|
97
|
checkAndSetHero(posts) {
|
|
102
|
98
|
const post = posts[this.$route.params.slug]
|
|
|
@@ -109,15 +105,14 @@ export default {
|
|
109
|
105
|
watch: {
|
|
110
|
106
|
posts(newVal, oldVal) {
|
|
111
|
107
|
// Loads images from the DOM
|
|
112
|
|
- this.checkForImages(newVal)
|
|
|
108
|
+ // this.checkForImages(newVal)
|
|
113
|
109
|
|
|
114
|
110
|
this.checkAndSetHero(newVal)
|
|
115
|
|
- console.log(this.galleries)
|
|
116
|
111
|
}
|
|
117
|
112
|
},
|
|
118
|
113
|
created() {
|
|
119
|
114
|
let type = convertTitleCase(this.$route.params.type)
|
|
120
|
|
-
|
|
|
115
|
+ this.$store.dispatch(`getMediaById`, [7])
|
|
121
|
116
|
if(!this[`all{type}Loaded`]) {
|
|
122
|
117
|
// console.log('Retrieving...', type)
|
|
123
|
118
|
this.$store.dispatch(`getAll${type}`)
|