Преглед на файлове

:bug: more fixes for hero loading | hero loading on welcome | direct links to posts for welcome page

tags/0.9.0
j преди 4 години
родител
ревизия
c31116cf25
променени са 3 файла, в които са добавени 46 реда и са изтрити 26 реда
  1. 28
    12
      vue-theme/src/pages/index.vue
  2. 13
    11
      vue-theme/src/pages/list.vue
  3. 5
    3
      vue-theme/src/pages/single.vue

+ 28
- 12
vue-theme/src/pages/index.vue Целия файл

@@ -3,30 +3,31 @@
3 3
 .page--index.f-row.between
4 4
     article.f-grow
5 5
         .f-row
6
-            h3(v-if="!allPagesLoaded ") loading...
6
+            h3(v-if="!allPagesLoaded") loading...
7 7
             .content(v-else-if="allPages['welcome']" v-html="allPages['welcome'].content")
8 8
         .f-row
9 9
             section(v-if="allEpisodesLoaded").shadow
10
-                router-link(:to="`./episodes`")
10
+                router-link(:to="`/episodes`")
11 11
                     h4.t-cap episodes
12
-                    p(v-if="Object.values(allEpisodes).length > 0") {{ Object.values(allEpisodes)[0].slug }}
13
-                    p(v-else) no episodes
12
+                router-link(:to="`/episodes/${Object.values(allEpisodes)[0].slug}`")
13
+                    p {{ Object.values(allEpisodes)[0].slug }}
14 14
 
15 15
             section(v-if="allArtistsLoaded").shadow
16
-                router-link(:to="`./artists`")
16
+                router-link(:to="`/artists`")
17 17
                     h4.t-cap artists
18
-                    p(v-if="Object.values(allArtists).length > 0") {{ Object.values(allArtists)[0].slug}}
19
-                    p(v-else) no artists
18
+                router-link(:to="`/artists/${Object.values(allArtists)[0].slug}`")
19
+                    p {{ Object.values(allArtists)[0].slug }}
20 20
 
21 21
             section(v-if="allPagesLoaded").shadow
22 22
                 h4.t-cap pages
23
-                    p(v-if="Object.values(allPages).length > 0") {{ Object.values(allPages)[0].slug }}
24
-                    p(v-else) no pages
23
+                    p {{ Object.values(allPages)[0].slug }}
24
+
25 25
         .f-row
26 26
             section(v-if="allPostsLoaded").shadow
27
-                router-link(:to="`./posts`")
27
+                router-link(:to="`/posts`")
28 28
                     h4.t-cap posts
29
-                    p(v-if="Object.values(allPosts).length > 0") {{ Object.values(allPosts)[0].slug }}
29
+                router-link(:to="`/posts/${Object.values(allPosts)[0].slug}`")
30
+                    p {{ Object.values(allPosts)[0].slug }}
30 31
      
31 32
         .f-row
32 33
             footer.f-col
@@ -43,11 +44,26 @@ export default {
43 44
     mixins: [postTypeGetters, scrollTop],
44 45
     created() {
45 46
         // console.log(wp)
46
-
47 47
         postTypes.forEach(type => {
48 48
             const capitalizedType = convertTitleCase(type)
49 49
             this.$store.dispatch(`getAll${capitalizedType}`)
50 50
         })
51
+        this.checkAndSetHero('welcome')
52
+    },
53
+    methods: {
54
+        async checkAndSetHero(type) {
55
+            if(!this['allPagesLoaded']) {
56
+                await this.$store.dispatch('getAllPages')    
57
+            }
58
+            const page = this.allPages[type]
59
+            if(!page) return
60
+            let json = { url: page.featured, heroType: 'image' }
61
+            if(page.hero && JSON.parse(page.hero) && JSON.parse(page.hero).url) {
62
+                json = JSON.parse(page.hero)
63
+                json.heroType = 'video'
64
+            }
65
+            this.$store.commit('SET_HERO', json)
66
+        },
51 67
     }
52 68
 }
53 69
 </script>

+ 13
- 11
vue-theme/src/pages/list.vue Целия файл

@@ -81,7 +81,7 @@ export default {
81 81
         },
82 82
     },
83 83
     methods: {
84
-        setHeroAndGetPosts() {
84
+        getPosts() {
85 85
             // Sorting
86 86
             let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
87 87
             
@@ -95,11 +95,13 @@ export default {
95 95
             // Don't dispatch if there's no type
96 96
             if(this.type && this.dispatchName) {
97 97
                 this.$store.dispatch(this.dispatchName, sort)
98
-                this.checkAndSetHero()
99 98
             }
100 99
         },
101
-        checkAndSetHero() {
102
-            const page = this.allPages[this.type]
100
+        async checkAndSetHero(type) {
101
+            if(!this['allPagesLoaded']) {
102
+                await this.$store.dispatch('getAllPages')
103
+            }
104
+            const page = this.allPages[type]
103 105
             if(!page) return
104 106
             let json = { url: page.featured, heroType: 'image' }
105 107
             if(page.hero && JSON.parse(page.hero) && JSON.parse(page.hero).url) {
@@ -114,16 +116,16 @@ export default {
114 116
             // console.log(this.sidebar)
115 117
             let type = convertTitleCase(this.type)
116 118
             let sort = this.sortBy ? this.sortBy : to.path.split('/').pop()
117
-            
118
-            await this.$store.dispatch('getAllPages')    
119
-            if(!this[`all${type}Loaded`] && this['allPagesLoaded'] || sort) this.setHeroAndGetPosts()
119
+            this.checkAndSetHero(this.type)
120
+            if(!this[`all${type}Loaded`] || sort) this.getPosts()
120 121
         }
121 122
     },
122
-    async created() {
123
+    created() {
123 124
         let type = convertTitleCase(this.type)
124
-        // console.log('already loaded ?:', this[`all${type}Loaded`])
125
-        await this.$store.dispatch('getAllPages')
126
-        if(!this[`all${type}Loaded`] && this['allPagesLoaded']) this.setHeroAndGetPosts()
125
+        console.log(`${type} already loaded?:`, this[`all${type}Loaded`])
126
+        
127
+        this.checkAndSetHero(this.type)
128
+        if(!this[`all${type}Loaded`]) this.getPosts()
127 129
     }
128 130
 }
129 131
 </script>

+ 5
- 3
vue-theme/src/pages/single.vue Целия файл

@@ -143,6 +143,7 @@ export default {
143 143
          * @param {object} posts
144 144
          */
145 145
         checkAndSetHero(post) {
146
+            // console.log(post)
146 147
             if(!post) return
147 148
             let json = { url: post.featured, heroType: 'image' }
148 149
             if(post.hero && JSON.parse(post.hero) && JSON.parse(post.hero).url) {
@@ -151,7 +152,7 @@ export default {
151 152
             }
152 153
             this.$store.commit('SET_HERO', json)
153 154
         },
154
-
155
+        
155 156
         /**
156 157
          * Date Object from unix strings from db
157 158
          */
@@ -190,14 +191,15 @@ export default {
190 191
     },
191 192
     watch: {
192 193
         post(newVal, oldVal) {
193
-            this.checkAndSetHero(newVal)
194
+            this.checkAndSetHero(this.post)
194 195
         },
195 196
         $route(newVal, oldVal) {
196 197
             this.loadPostData()
197 198
         }
198 199
     },
199 200
     async created() {
200
-        this.loadPostData()
201
+        await this.loadPostData()
202
+        this.checkAndSetHero(this.post)
201 203
     }
202 204
 }
203 205
 </script>

Loading…
Отказ
Запис