Bläddra i källkod

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

tags/0.9.0
j 4 år sedan
förälder
incheckning
c31116cf25
3 ändrade filer med 46 tillägg och 26 borttagningar
  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 Visa fil

3
 .page--index.f-row.between
3
 .page--index.f-row.between
4
     article.f-grow
4
     article.f-grow
5
         .f-row
5
         .f-row
6
-            h3(v-if="!allPagesLoaded ") loading...
6
+            h3(v-if="!allPagesLoaded") loading...
7
             .content(v-else-if="allPages['welcome']" v-html="allPages['welcome'].content")
7
             .content(v-else-if="allPages['welcome']" v-html="allPages['welcome'].content")
8
         .f-row
8
         .f-row
9
             section(v-if="allEpisodesLoaded").shadow
9
             section(v-if="allEpisodesLoaded").shadow
10
-                router-link(:to="`./episodes`")
10
+                router-link(:to="`/episodes`")
11
                     h4.t-cap episodes
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
             section(v-if="allArtistsLoaded").shadow
15
             section(v-if="allArtistsLoaded").shadow
16
-                router-link(:to="`./artists`")
16
+                router-link(:to="`/artists`")
17
                     h4.t-cap artists
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
             section(v-if="allPagesLoaded").shadow
21
             section(v-if="allPagesLoaded").shadow
22
                 h4.t-cap pages
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
         .f-row
25
         .f-row
26
             section(v-if="allPostsLoaded").shadow
26
             section(v-if="allPostsLoaded").shadow
27
-                router-link(:to="`./posts`")
27
+                router-link(:to="`/posts`")
28
                     h4.t-cap posts
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
         .f-row
32
         .f-row
32
             footer.f-col
33
             footer.f-col
43
     mixins: [postTypeGetters, scrollTop],
44
     mixins: [postTypeGetters, scrollTop],
44
     created() {
45
     created() {
45
         // console.log(wp)
46
         // console.log(wp)
46
-
47
         postTypes.forEach(type => {
47
         postTypes.forEach(type => {
48
             const capitalizedType = convertTitleCase(type)
48
             const capitalizedType = convertTitleCase(type)
49
             this.$store.dispatch(`getAll${capitalizedType}`)
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
 </script>
69
 </script>

+ 13
- 11
vue-theme/src/pages/list.vue Visa fil

81
         },
81
         },
82
     },
82
     },
83
     methods: {
83
     methods: {
84
-        setHeroAndGetPosts() {
84
+        getPosts() {
85
             // Sorting
85
             // Sorting
86
             let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
86
             let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
87
             
87
             
95
             // Don't dispatch if there's no type
95
             // Don't dispatch if there's no type
96
             if(this.type && this.dispatchName) {
96
             if(this.type && this.dispatchName) {
97
                 this.$store.dispatch(this.dispatchName, sort)
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
             if(!page) return
105
             if(!page) return
104
             let json = { url: page.featured, heroType: 'image' }
106
             let json = { url: page.featured, heroType: 'image' }
105
             if(page.hero && JSON.parse(page.hero) && JSON.parse(page.hero).url) {
107
             if(page.hero && JSON.parse(page.hero) && JSON.parse(page.hero).url) {
114
             // console.log(this.sidebar)
116
             // console.log(this.sidebar)
115
             let type = convertTitleCase(this.type)
117
             let type = convertTitleCase(this.type)
116
             let sort = this.sortBy ? this.sortBy : to.path.split('/').pop()
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
         let type = convertTitleCase(this.type)
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
 </script>
131
 </script>

+ 5
- 3
vue-theme/src/pages/single.vue Visa fil

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

Laddar…
Avbryt
Spara