From d3d919c95b3c1d3d55a044ccbb257f1a7d93b797 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Mon, 27 Dec 2021 12:59:17 -0500 Subject: [PATCH] [F] Tag: Remove post from query if post doesn't contain this tag --- src/components/Tag.vue | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/Tag.vue b/src/components/Tag.vue index 01a88ed..86ff9b4 100644 --- a/src/components/Tag.vue +++ b/src/components/Tag.vue @@ -11,6 +11,7 @@ import {Options, Vue} from 'vue-class-component'; import {Prop, Ref} from "vue-property-decorator"; import {pushQuery} from "@/scripts/router"; +import {staticMeta} from '@/views/Blog.vue' @Options({components: {}}) export default class Tag extends Vue @@ -22,9 +23,24 @@ export default class Tag extends Vue clickTag(e: PointerEvent): void { - const t = this.tagName ?? this.el.innerText e.stopPropagation() - pushQuery({tag: t}) + + const t = this.tagName ?? this.el.innerText + 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 + } + } + + pushQuery(q) } }