|
|
@@ -70,11 +70,15 @@ export default {
|
|
70
|
70
|
setHeroAndGetPosts() {
|
|
71
|
71
|
let type = convertTitleCase(this.type)
|
|
72
|
72
|
|
|
|
73
|
+ let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
|
|
|
74
|
+
|
|
|
75
|
+ console.log('trying to sort by:, sort')
|
|
|
76
|
+
|
|
73
|
77
|
// Seperate sorting from post slugs
|
|
74
|
|
- if(!this.sortBy || Object.values(sortTypes).indexOf(this.sortBy) >= 0) {
|
|
|
78
|
+ if(sort && Object.values(sortTypes).includes(sort)) {
|
|
75
|
79
|
// Don't dispatch if there's no type
|
|
76
|
80
|
if(this.type) {
|
|
77
|
|
- this.$store.dispatch(this.dispatchName, this.sortBy)
|
|
|
81
|
+ this.$store.dispatch(this.dispatchName, sort)
|
|
78
|
82
|
}
|
|
79
|
83
|
}
|
|
80
|
84
|
if(this.$store.state.hero.url !== type) this.$store.commit('SET_HERO', type)
|
|
|
@@ -83,7 +87,8 @@ export default {
|
|
83
|
87
|
watch: {
|
|
84
|
88
|
$route(to, from){
|
|
85
|
89
|
let type = convertTitleCase(this.type)
|
|
86
|
|
- if(!this[`all${type}Loaded`]) this.setHeroAndGetPosts()
|
|
|
90
|
+ let sort = this.sortBy ? this.sortBy : to.path.split('/').pop()
|
|
|
91
|
+ if(!this[`all${type}Loaded`] || sort) this.setHeroAndGetPosts()
|
|
87
|
92
|
}
|
|
88
|
93
|
},
|
|
89
|
94
|
created() {
|