From 6aa2eca8997c0cef3374d2fd934fcd7a06884156 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 11 Sep 2022 10:40:18 -0400 Subject: [PATCH] [F] Fix blog post filtering --- src/components/BlogIndex.vue | 56 +++++++++++++++++++++++++++++++++--- src/components/Tag.vue | 24 +--------------- src/views/Blog.vue | 8 ++++-- 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/src/components/BlogIndex.vue b/src/components/BlogIndex.vue index 07e9b2e..b4592a8 100644 --- a/src/components/BlogIndex.vue +++ b/src/components/BlogIndex.vue @@ -1,9 +1,11 @@ @@ -21,9 +23,55 @@ export default class BlogIndexLinks extends Vue meta: BlogMeta = staticMeta - click(c: [string, number]): void + clickCat(e: MouseEvent, cat: [string, number]): void { - pushQuery({category: c[0]}) + e.stopPropagation() + + const c = cat[0] + const q: { [id: string]: string | null } = {category: c} + + // Check if the currently selected post is in this category + // const url_name = this.$route.query.post + // if (url_name) + // { + // const posts = staticMeta.posts.filter(it => it.url_name == url_name) + // if (posts && posts[0].category != c) + // { + // // Doesn't include tag, remove post selection + // q.post = null + // } + // } + + // Clear tag selection + q.tag = null + + pushQuery(q) + } + + + clickTag(e: MouseEvent, tag: [string, number]): void + { + e.stopPropagation() + + const t = tag[0] + const q: { [id: string]: string | null } = {tag: t} + + // Check if the currently selected post is in this tag + // const url_name = this.$route.query.post + // if (url_name) + // { + // const posts = staticMeta.posts.filter(it => it.url_name == url_name) + // if (posts && !posts[0].tags.includes(t)) + // { + // // Doesn't include tag, remove post selection + // q.post = null + // } + // } + + // Clear category selection + q.category = null + + pushQuery(q) } } diff --git a/src/components/Tag.vue b/src/components/Tag.vue index 204308e..06e372c 100644 --- a/src/components/Tag.vue +++ b/src/components/Tag.vue @@ -1,5 +1,5 @@