From 2c3fa81227b862a7a5ba0b7cfcdedc671591edde Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Wed, 14 Apr 2021 17:11:55 +0200 Subject: [PATCH] Display categories in sidebar if no pages set (#292) Fixes #291 --- .../src/components/UI/CategorySidebar.vue | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/UI/CategorySidebar.vue b/frontend/src/components/UI/CategorySidebar.vue index 58373847bb01..7fd349579f54 100644 --- a/frontend/src/components/UI/CategorySidebar.vue +++ b/frontend/src/components/UI/CategorySidebar.vue @@ -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) {