Kaynağa Gözat

:sparkles: adding featured image support for list.vue

tags/0.9.0
j 4 yıl önce
ebeveyn
işleme
541cf999f1

+ 3
- 0
vue-theme/src/components/hero.vue Dosyayı Görüntüle

70
     background-color: rebeccapurple
70
     background-color: rebeccapurple
71
     min-height: 35%
71
     min-height: 35%
72
     width: 100%
72
     width: 100%
73
+    &--image
74
+        > img
75
+            max-width: 100%
73
     .embedded
76
     .embedded
74
         height: 100%
77
         height: 100%
75
         width: 100%
78
         width: 100%

+ 2
- 0
vue-theme/src/components/sidebars/sidebar.vue Dosyayı Görüntüle

31
 </template>
31
 </template>
32
 
32
 
33
 <script>
33
 <script>
34
+import relatedSidebar from './related'
34
 import exhibitionsSidebar from './exhibitions'
35
 import exhibitionsSidebar from './exhibitions'
35
 import eventsSidebar from './events'
36
 import eventsSidebar from './events'
36
 import { sortTypes } from '@/utils/helpers'
37
 import { sortTypes } from '@/utils/helpers'
50
     components: {
51
     components: {
51
         exhibitionsSidebar,
52
         exhibitionsSidebar,
52
         eventsSidebar,
53
         eventsSidebar,
54
+        relatedSidebar
53
     },
55
     },
54
     data() {
56
     data() {
55
         return {
57
         return {

+ 18
- 14
vue-theme/src/pages/list.vue Dosyayı Görüntüle

81
         },
81
         },
82
     },
82
     },
83
     methods: {
83
     methods: {
84
-        getThumbnailFromYt(url) {
85
-            return ytThumbnail(url, 'medium')
86
-        },
87
         setHeroAndGetPosts() {
84
         setHeroAndGetPosts() {
88
-            let type = convertTitleCase(this.type)
89
-            
90
             // Sorting
85
             // Sorting
91
             let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
86
             let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
92
             
87
             
100
             // Don't dispatch if there's no type
95
             // Don't dispatch if there's no type
101
             if(this.type) {
96
             if(this.type) {
102
                 this.$store.dispatch(this.dispatchName, sort)
97
                 this.$store.dispatch(this.dispatchName, sort)
98
+                this.checkAndSetHero()
103
             }
99
             }
104
-            
105
-            if(this.$store.state.hero.url !== type) this.$store.commit('SET_HERO', type)
106
-        }
100
+        },
101
+        checkAndSetHero() {
102
+            const page = this.allPages[this.type]
103
+            if(!page) return
104
+            let json = { url: page.featured, heroType: 'image' }
105
+            if(page.hero && JSON.parse(page.hero).url) {
106
+                json = JSON.parse(page.hero)
107
+                json.heroType = 'video'
108
+            }
109
+            this.$store.commit('SET_HERO', json)
110
+        },
107
     },
111
     },
108
     watch: {
112
     watch: {
109
-        $route(to, from){
113
+        async $route(to, from){
110
             // console.log(this.sidebar)
114
             // console.log(this.sidebar)
111
             let type = convertTitleCase(this.type)
115
             let type = convertTitleCase(this.type)
112
             let sort = this.sortBy ? this.sortBy : to.path.split('/').pop()
116
             let sort = this.sortBy ? this.sortBy : to.path.split('/').pop()
113
             
117
             
114
-            this.$store.dispatch('getAllPages')    
115
-            if(!this[`all${type}Loaded`] || sort) this.setHeroAndGetPosts()
118
+            await this.$store.dispatch('getAllPages')    
119
+            if(!this[`all${type}Loaded`] && this['allPagesLoaded'] || sort) this.setHeroAndGetPosts()
116
         }
120
         }
117
     },
121
     },
118
-    created() {
122
+    async created() {
119
         let type = convertTitleCase(this.type)
123
         let type = convertTitleCase(this.type)
120
         // console.log('already loaded ?:', this[`all${type}Loaded`])
124
         // console.log('already loaded ?:', this[`all${type}Loaded`])
121
-        this.$store.dispatch('getAllPages')
122
-        if(!this[`all${type}Loaded`]) this.setHeroAndGetPosts()
125
+        await this.$store.dispatch('getAllPages')
126
+        if(!this[`all${type}Loaded`] && this['allPagesLoaded']) this.setHeroAndGetPosts()
123
     }
127
     }
124
 }
128
 }
125
 </script>
129
 </script>

+ 1
- 2
vue-theme/src/pages/single.vue Dosyayı Görüntüle

134
             this.activeImageID = imageInfo.dataset.id ? parseInt(imageInfo.dataset.id) : parseInt(imageInfo.className.split('-').pop())
134
             this.activeImageID = imageInfo.dataset.id ? parseInt(imageInfo.dataset.id) : parseInt(imageInfo.className.split('-').pop())
135
         },
135
         },
136
         closeGallery() {
136
         closeGallery() {
137
-            this.activeGalleryIndex = -1
138
-            this.activeImageID = -1
137
+            this.activeGalleryIndex = this.activeImageID = -1
139
         },
138
         },
140
         /**
139
         /**
141
          * Everytime the posts object changes
140
          * Everytime the posts object changes

+ 2
- 17
vue-theme/src/store/modules/page.js Dosyayı Görüntüle

4
 const state = {
4
 const state = {
5
     all: [],
5
     all: [],
6
     loaded: false,
6
     loaded: false,
7
-    singlePage: null,
8
 }
7
 }
9
 
8
 
10
 // getters
9
 // getters
15
 
14
 
16
 // actions
15
 // actions
17
 const actions = {
16
 const actions = {
18
-    getAllPages({ commit }, sortType) {
17
+    async getAllPages({ commit }, sortType) {
19
         commit('PAGES_LOADED', false)
18
         commit('PAGES_LOADED', false)
20
-        return api.getByType('pages', sortType, pages => {
19
+        return await api.getByType('pages', sortType, pages => {
21
             commit('STORE_FETCHED_PAGES', { pages })
20
             commit('STORE_FETCHED_PAGES', { pages })
22
             commit('PAGES_LOADED', true)
21
             commit('PAGES_LOADED', true)
23
         })
22
         })
24
     },
23
     },
25
-    getSinglePage({ commit }, id) {
26
-        commit('CLEAR_SINGLE_PAGE')
27
-        commit('PAGES_LOADED', false)
28
-        api.getSingleType('pages', id, page => {
29
-            commit('STORE_FETCHED_SINGLE_PAGE', page)
30
-            commit('PAGES_LOADED', true)
31
-        })
32
-    },
33
 }
24
 }
34
 
25
 
35
 // mutations
26
 // mutations
37
     STORE_FETCHED_PAGES(state, { pages }) {
28
     STORE_FETCHED_PAGES(state, { pages }) {
38
         state.all = pages
29
         state.all = pages
39
     },
30
     },
40
-    STORE_FETCHED_SINGLE_PAGE(state, page) {
41
-        state.singlePage = page
42
-    },
43
     CLEAR_PAGES(state) {
31
     CLEAR_PAGES(state) {
44
         state.all = []
32
         state.all = []
45
     },
33
     },
46
-    CLEAR_SINGLE_PAGE(state) {
47
-        state.singlePage = null
48
-    },
49
     PAGES_LOADED(state, val) {
34
     PAGES_LOADED(state, val) {
50
         state.loaded = val
35
         state.loaded = val
51
     },
36
     },

Loading…
İptal
Kaydet