Display categories in sidebar if no pages set (#292)

Fixes  #291
This commit is contained in:
sephrat 2021-04-14 17:11:55 +02:00 committed by GitHub
parent b726c9a886
commit 2c3fa81227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,17 +59,6 @@ export default {
], ],
}; };
}, },
computed: {
allCategories() {
return this.$store.getters.getCategories;
},
},
watch: {
allCategories() {
this.buildSidebar();
},
showSidebar() {},
},
mounted() { mounted() {
this.buildSidebar(); this.buildSidebar();
this.mobile = this.viewScale(); this.mobile = this.viewScale();
@ -81,14 +70,27 @@ export default {
this.links = []; this.links = [];
this.links.push(...this.baseLinks); this.links.push(...this.baseLinks);
const pages = await api.siteSettings.getPages(); const pages = await api.siteSettings.getPages();
pages.sort((a, b) => a.position - b.position); if(pages.length > 0) {
pages.forEach(async element => { pages.sort((a, b) => a.position - b.position);
this.links.push({ pages.forEach(async element => {
title: element.name, this.links.push({
to: `/pages/${element.slug}`, title: element.name,
icon: "mdi-tag", to: `/pages/${element.slug}`,
icon: "mdi-tag",
});
}); });
}); }
else {
const categories = await api.categories.getAll();
categories.forEach(async element => {
this.links.push({
title: element.name,
to: `/recipes/category/${element.slug}`,
icon: "mdi-tag",
});
});
}
}, },
viewScale() { viewScale() {
switch (this.$vuetify.breakpoint.name) { switch (this.$vuetify.breakpoint.name) {