Skip to content

Commit

Permalink
add searchability to tags displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
thooyork committed May 9, 2023
1 parent 79b848b commit d00336f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion client/src/components/DisplayTags.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="badge-container">
<div v-for="tag in tags" :key="tag.id" class="badge me-1">
<div v-for="tag in tags" :key="tag.id" class="badge me-1" @click="searchWord(tag.name)">
{{ tag.name }}
</div>
</div>
Expand All @@ -14,13 +14,22 @@
.badge {
background-color: $badge-background-color;
color: $badge-text-color;
cursor: pointer;
}
}
</style>

<script setup lang="ts">
import type { Tag } from "@fumix/fu-blog-common";
import type { PropType } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const props = defineProps({ tags: { type: Array as PropType<Tag[]>, required: true } });
const searchWord = (word: string): void => {
if (word) {
router.push(`/posts/?search=${word}&operator=and`);
}
};
</script>
1 change: 0 additions & 1 deletion client/src/views/PostsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ const goTo = (path: string) => {
};
const searchWord = (event: any) => {
console.log("SEARCH -------->", event);
goTo(`/posts/?search=${event[0]}&operator=and`);
};
Expand Down

0 comments on commit d00336f

Please sign in to comment.