adding alphabetical auto-sorting of resources

This commit is contained in:
Erin RIvas
2019-08-16 22:41:34 -05:00
parent 8cdf22580f
commit 9bc5d9ab5d

View File

@@ -43,10 +43,20 @@ export default {
resource.path = `${pagePath}?card=${resource.cleanTitle}`
resource.active = (resource.cleanTitle === query) ? 'card--active' : ''
}
return category
category.resources.sort(this.compareTitles)
return category
},
},
methods: {
compareTitles(x, y) {
if (x.cleanTitle > y.cleanTitle) {
return 1
} else if (x.cleanTitle < y.cleanTitle) {
return -1
} else {
return 0
}
},
onToggle(index) {
if (this.activeCard === index) {
this.activeCard = null;