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() {
this.buildSidebar();
this.mobile = this.viewScale();
@ -81,14 +70,27 @@ export default {
this.links = [];
this.links.push(...this.baseLinks);
const pages = await api.siteSettings.getPages();
pages.sort((a, b) => a.position - b.position);
pages.forEach(async element => {
this.links.push({
title: element.name,
to: `/pages/${element.slug}`,
icon: "mdi-tag",
if(pages.length > 0) {
pages.sort((a, b) => a.position - b.position);
pages.forEach(async element => {
this.links.push({
title: element.name,
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() {
switch (this.$vuetify.breakpoint.name) {