Przeglądaj źródła

:sparkles: adding featured image support for list.vue

tags/0.9.0
j 4 lat temu
rodzic
commit
541cf999f1

+ 3
- 0
vue-theme/src/components/hero.vue Wyświetl plik

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

+ 2
- 0
vue-theme/src/components/sidebars/sidebar.vue Wyświetl plik

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

+ 18
- 14
vue-theme/src/pages/list.vue Wyświetl plik

@@ -81,12 +81,7 @@ export default {
81 81
         },
82 82
     },
83 83
     methods: {
84
-        getThumbnailFromYt(url) {
85
-            return ytThumbnail(url, 'medium')
86
-        },
87 84
         setHeroAndGetPosts() {
88
-            let type = convertTitleCase(this.type)
89
-            
90 85
             // Sorting
91 86
             let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
92 87
             
@@ -100,26 +95,35 @@ export default {
100 95
             // Don't dispatch if there's no type
101 96
             if(this.type) {
102 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 112
     watch: {
109
-        $route(to, from){
113
+        async $route(to, from){
110 114
             // console.log(this.sidebar)
111 115
             let type = convertTitleCase(this.type)
112 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 123
         let type = convertTitleCase(this.type)
120 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 129
 </script>

+ 1
- 2
vue-theme/src/pages/single.vue Wyświetl plik

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

+ 2
- 17
vue-theme/src/store/modules/page.js Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz