|
|
@@ -6,17 +6,16 @@
|
|
6
|
6
|
span(v-if="sortBy")
|
|
7
|
7
|
h1 sorted by {{ sortBy.replace('-', ' ') }}
|
|
8
|
8
|
|
|
9
|
|
- section.shadow
|
|
10
|
|
- h4 {{ type }}
|
|
11
|
|
- p {{ Object.values(posts).length }}
|
|
12
|
|
- p {{ sidebar }}
|
|
13
|
|
-
|
|
14
|
9
|
.posts(:class="{ 'is-grid': isGrid }")
|
|
15
|
10
|
section(v-for="post in posts").shadow
|
|
16
|
11
|
router-link(:to="`/${type}/${post.slug}`")
|
|
17
|
12
|
h4 {{ post.title }}
|
|
18
|
13
|
p(style="font-size: 9px;") {{ post.date }}
|
|
19
|
14
|
|
|
|
15
|
+ footer
|
|
|
16
|
+ p {{ `${type} count: ${Object.values(posts).length}` }}
|
|
|
17
|
+ p {{ `show sidebar: ${sidebar}` }}
|
|
|
18
|
+
|
|
20
|
19
|
sidebar(v-if="sidebar" :type="`${type}`")
|
|
21
|
20
|
.shadow
|
|
22
|
21
|
h1.t-up slots stuff
|
|
|
@@ -61,6 +60,10 @@ export default {
|
|
61
|
60
|
type() { // Checks for type and fixes Episodes route edge case
|
|
62
|
61
|
return typeFromRoute(this.$route)
|
|
63
|
62
|
},
|
|
|
63
|
+ dispatchName() {
|
|
|
64
|
+ let type = convertTitleCase(this.type)
|
|
|
65
|
+ return this.sortBy ? `getAll${type.split('/')[0]}` : `getAll${type}`
|
|
|
66
|
+ },
|
|
64
|
67
|
posts() {
|
|
65
|
68
|
let type = convertTitleCase(this.type)
|
|
66
|
69
|
|
|
|
@@ -75,27 +78,24 @@ export default {
|
|
75
|
78
|
return this.sortBy ? this[`all${type}`] : sortedByRecent
|
|
76
|
79
|
},
|
|
77
|
80
|
},
|
|
78
|
|
- watch: {
|
|
79
|
|
- $route(to, from){
|
|
80
|
|
- let type = convertTitleCase(to.path.slice(1))
|
|
|
81
|
+ methods: {
|
|
|
82
|
+ setHeroAndGetPosts() {
|
|
|
83
|
+ let type = convertTitleCase(this.type)
|
|
81
|
84
|
|
|
82
|
|
- // Accounts for the sort-by in URL case
|
|
83
|
|
- let dispatchName = this.sortBy ? `getAll${type.split('/')[0]}` : `getAll${type}`
|
|
84
|
|
-
|
|
85
|
85
|
// Seperate sorting from post slugs
|
|
86
|
|
- if(Object.values(sortTypes).indexOf(this.sortBy) >= 0) {
|
|
87
|
|
- this.$store.dispatch(dispatchName, this.sortBy)
|
|
88
|
|
- }
|
|
89
|
|
- if(this.$store.state.hero.url !== type) {
|
|
90
|
|
- this.$store.commit('SET_HERO', type)
|
|
|
86
|
+ if(!this.sortBy || Object.values(sortTypes).indexOf(this.sortBy) >= 0) {
|
|
|
87
|
+ this.$store.dispatch(this.dispatchName, this.sortBy)
|
|
91
|
88
|
}
|
|
|
89
|
+ if(this.$store.state.hero.url !== type) this.$store.commit('SET_HERO', type)
|
|
|
90
|
+ }
|
|
|
91
|
+ },
|
|
|
92
|
+ watch: {
|
|
|
93
|
+ $route(to, from){
|
|
|
94
|
+ this.setHeroAndGetPosts()
|
|
92
|
95
|
}
|
|
93
|
96
|
},
|
|
94
|
97
|
created() {
|
|
95
|
|
- let type = convertTitleCase(this.type)
|
|
96
|
|
-
|
|
97
|
|
- this.$store.dispatch(`getAll${type}`, this.sortBy)
|
|
98
|
|
- this.$store.commit('SET_HERO', type)
|
|
|
98
|
+ this.setHeroAndGetPosts()
|
|
99
|
99
|
}
|
|
100
|
100
|
}
|
|
101
|
101
|
</script>
|