ソースを参照

:recycle: running some obj checks

tags/1.0.1^2^2
J 3年前
コミット
a6bde347c1
1個のファイルの変更10行の追加10行の削除
  1. 10
    10
      vue-theme/src/pages/single.vue

+ 10
- 10
vue-theme/src/pages/single.vue ファイルの表示

91
             if (!this.singlePost.galleries) return
91
             if (!this.singlePost.galleries) return
92
             const galleries = []
92
             const galleries = []
93
             this.singlePost.galleries.forEach(gallery => {
93
             this.singlePost.galleries.forEach(gallery => {
94
-                const withImages = {}
94
+                const withImages = []
95
                 gallery.ids.forEach(imageId => {
95
                 gallery.ids.forEach(imageId => {
96
-                    withImages[imageId] = this.singlePost.attached[imageId]
96
+                    withImages.push(this.singlePost.attached[imageId])
97
                 })
97
                 })
98
                 galleries.push(withImages)
98
                 galleries.push(withImages)
99
             })
99
             })
102
         activeGalleryImages() {
102
         activeGalleryImages() {
103
             if (!this.singlePostGalleries || this.activeGalleryIndex < 0)
103
             if (!this.singlePostGalleries || this.activeGalleryIndex < 0)
104
                 return []
104
                 return []
105
-            return Object.values(
106
-                this.singlePostGalleries[this.activeGalleryIndex],
107
-            )
105
+            return this.singlePostGalleries[this.activeGalleryIndex]
108
         },
106
         },
109
         p2pPostsByType() {
107
         p2pPostsByType() {
110
             return this.singlePost && this.singlePost.relatedto
108
             return this.singlePost && this.singlePost.relatedto
198
         },
196
         },
199
         async singlePost(post) {
197
         async singlePost(post) {
200
             console.log('---')
198
             console.log('---')
199
+            if (!this.$el) return
201
             const content = this.$el.children[0].querySelector('section')
200
             const content = this.$el.children[0].querySelector('section')
202
             await nextTick()
201
             await nextTick()
203
             const galleries = content.querySelectorAll('.wp-block-gallery')
202
             const galleries = content.querySelectorAll('.wp-block-gallery')
204
             const cb = e => {
203
             const cb = e => {
205
                 this.activeGalleryIndex = parseInt(e.target.dataset.gallery)
204
                 this.activeGalleryIndex = parseInt(e.target.dataset.gallery)
206
-                const galleryImages = Object.keys(
207
-                    this.singlePostGalleries[this.activeGalleryIndex],
208
-                )
209
-                this.activeImageIndex = parseInt(
210
-                    galleryImages.indexOf(e.target.dataset.id),
205
+                const galleryImages =
206
+                    this.singlePost.galleries[this.activeGalleryIndex]
207
+                console.log(galleryImages)
208
+                if (!galleryImages.ids) return
209
+                this.activeImageIndex = galleryImages.ids.indexOf(
210
+                    parseInt(e.target.dataset.id),
211
                 )
211
                 )
212
                 console.log(
212
                 console.log(
213
                     `opening gallery: ${this.activeGalleryIndex}.${this.activeImageIndex}`,
213
                     `opening gallery: ${this.activeGalleryIndex}.${this.activeImageIndex}`,

読み込み中…
キャンセル
保存