Browse Source

:fire: just chopping some vars

tags/0.9.0
J 4 years ago
parent
commit
97d9c3e06a
2 changed files with 31 additions and 20 deletions
  1. 28
    9
      vue-theme/src/pages/list.vue
  2. 3
    11
      vue-theme/src/pages/single.vue

+ 28
- 9
vue-theme/src/pages/list.vue View File

@@ -34,6 +34,9 @@ import { postTypes, sortTypes, convertTitleCase } from '@/utils/helpers'
34 34
 
35 35
 const TIMEOUT = 1
36 36
 const INTERSECT_SELECTOR = '.page--list > article footer'
37
+const wideTypes = ['event', 'exhibition']
38
+const gridTypes = ['episode', 'artist']
39
+const sansSidebarTypes = ['episode']
37 40
 
38 41
 export default {
39 42
     components: { sidebar, featuredImage, card },
@@ -48,15 +51,31 @@ export default {
48 51
         }
49 52
     },
50 53
     computed: {
51
-        type: () => this.$route.params.type,
52
-        sortBy: () => this.$route.params.sortBy,
53
-        grid: () => this.type ? ['episode', 'artist'].includes(this.type) : null,
54
-        isWide: () => this.type ? ['event', 'exhibition'].includes(this.type) : null,
55
-        sidebar: () => this.type ? !['episode'].includes(this.type) : null,
56
-        shouldLoadAllAtOnce: () => this.type == 'episode' || this.type == 'artist' && this.sortBy == sortTypes.material,
57
-        pType: () => this.type ? `${convertTitleCase(this.type)}s` : null,
58
-        loaded: () => this.pType ? this[`all${this.pType}Loaded`] : false,
59
-        posts: () => this.pType ? this[`all${this.pType}`] : []
54
+        grid: () => this.type ? gridTypes.includes(this.type) : null,
55
+        isWide: () => this.type ? wideTypes.includes(this.type) : null,
56
+        sidebar: () => this.type ? !sansSidebarTypes.includes(this.type) : null,
57
+        type() {
58
+            // Checks for type and fixes Episodes route edge case
59
+            return this.$route.params.type
60
+        },
61
+        sortBy() {
62
+            return this.$route.params.sortBy
63
+        },
64
+        pType() {
65
+            if(!this.type) return
66
+            return `${convertTitleCase(this.type)}s`
67
+        },
68
+        loaded() {
69
+            if (!this.pType) return
70
+            return this[`all${this.pType}Loaded`]
71
+        },
72
+        posts() {
73
+            if (!this.pType) return
74
+            return this[`all${this.pType}`]
75
+        },
76
+        shouldLoadAllAtOnce() {
77
+            return this.type == 'episode' || this.type == 'artist' && this.sortBy == sortTypes.material
78
+        }
60 79
     },
61 80
     methods: {
62 81
         async loadMorePosts(shouldClear) {

+ 3
- 11
vue-theme/src/pages/single.vue View File

@@ -35,7 +35,7 @@
35 35
         footer.f-col
36 36
             img(src="../star.svg")
37 37
 
38
-    sidebar(v-if="sidebar" :type="`${type}`" layout="single" :related="p2pPostsByType")
38
+    sidebar(:type="`${type}`" layout="single" :related="p2pPostsByType")
39 39
 </template>
40 40
 
41 41
 <script>
@@ -63,16 +63,8 @@ export default {
63 63
         }
64 64
     },
65 65
     computed: {
66
-        sidebar() {
67
-            return true
68
-        },
69
-        slug() {
70
-            return this.$route.params.slug
71
-        },
72
-        type() {
73
-            // Checks for type and fixes Episodes route edge case
74
-            return this.$route.params.type
75
-        },
66
+        slug: () => this.$route.params.slug,
67
+        type: () => this.$route.params.type,
76 68
         /**
77 69
          * We get the actual post data using the slug
78 70
          * Careful with name collisions with vuex helpers

Loading…
Cancel
Save