Find resources from store

This commit is contained in:
Kevin Van Der Werff
2019-06-22 04:05:03 +02:00
parent f1a8d056d7
commit 48aeb6f804
2 changed files with 9 additions and 4 deletions

View File

@@ -13,12 +13,11 @@ export default {
data () {
return {
categoryRouteTitle: this.$route.params.category,
categories: this.$store.state.resources,
}
},
computed: {
category() {
return this.categories.find(category => category.title.toLowerCase() === this.categoryRouteTitle.toLowerCase())
category() {
return this.$store.getters['resources/findResources'](this.categoryRouteTitle)
}
},
components: { Card },

View File

@@ -1,3 +1,9 @@
import resources from '../resources/'
export const state = () => resources
export const state = () => resources
export const getters = {
findResources: state => title => {
return state.find(resource => resource.title.toLowerCase() === title.toLowerCase())
}
}