Skip to content

Commit

Permalink
Review address
Browse files Browse the repository at this point in the history
Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
  • Loading branch information
SagarGi committed Jun 4, 2024
1 parent bc47cf9 commit 38ab3e7
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,18 @@ const loading = ref(false)
const filterBy = ref(null)
const sortBy = ref(null)
const homeViewMode = ref(null)
const searchPlaceHolder = ref("anything")
const searchPlaceHolder = ref("")
onMounted(async () => {
init()
tracker.trackPageView()
})
const getSearchPlaceHolder = computed(() => {
return "search by " + searchPlaceHolder.value
if (currentRoute.value.params.filterBy) {
return "search by " + searchPlaceHolder.value
}
return "search"
})
const init = () => {
Expand Down Expand Up @@ -176,18 +179,22 @@ const makeSearch = () => {
searchResultBlog.value = []
if (filterBy.value) {
peekData.value.forEach(item => {
if (filterBy.value === "tag") {
switch (filterBy.value) {
case "tag" :
if (item.tags && item.tags.join(" ").toLowerCase().includes(searchVal)) {
searchResultBlog.value.push(item)
}
} else if (filterBy.value === "author") {
if (item.authorName.toLowerCase().includes(searchVal)) {
break
case "author" :
if (item.tags && item.tags.join(" ").toLowerCase().includes(searchVal)) {
searchResultBlog.value.push(item)
}
} else {
break
case "title":
if (item.title.toLowerCase().includes(searchVal)) {
searchResultBlog.value.push(item)
}
break
}
})
} else if (sortBy.value) {
Expand All @@ -197,6 +204,7 @@ const makeSearch = () => {
}
})
} else {
// by default user can search with any of the options (author, title, tags)
peekData.value.forEach(item => {
if ((item.tags && item.tags.join(" ").toLowerCase().includes(searchVal)) || (item.authorName.toLowerCase().includes(searchVal)) || (item.title.toLowerCase().includes(searchVal))) {
searchResultBlog.value.push(item)
Expand Down

0 comments on commit 38ab3e7

Please sign in to comment.