Enable hashtag search
This commit is contained in:
parent
48f9c1800a
commit
d16981c2b5
3 changed files with 20 additions and 4 deletions
|
@ -46,7 +46,7 @@ export interface Mention {
|
|||
url: string;
|
||||
}
|
||||
|
||||
export interface PostTag {
|
||||
export interface Tag {
|
||||
name: string;
|
||||
url: string;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ export interface Post {
|
|||
reblogs_count: number;
|
||||
media_attachments: Attachment[];
|
||||
mentions: Mention[];
|
||||
tags: PostTag[];
|
||||
tags: Tag[];
|
||||
favourited: boolean;
|
||||
reblogged: boolean;
|
||||
ipfs_cid: string | null;
|
||||
|
|
|
@ -2,12 +2,13 @@ import { BACKEND_URL } from "@/constants"
|
|||
|
||||
import { createDidFromEthereumAddress } from "@/utils/did"
|
||||
import { http } from "./common"
|
||||
import { Post } from "./posts"
|
||||
import { Post, Tag } from "./posts"
|
||||
import { Profile } from "./users"
|
||||
|
||||
interface SearchResults {
|
||||
accounts: Profile[];
|
||||
statuses: Post[];
|
||||
hashtags: Tag[];
|
||||
}
|
||||
|
||||
export async function getSearchResults(
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<template v-if="errorMessage">{{ errorMessage }}</template>
|
||||
<template v-else-if="profiles.length > 0">{{ profiles.length }} people</template>
|
||||
<template v-else-if="posts.length > 0">{{ posts.length }} posts</template>
|
||||
<template v-else-if="tags.length > 0">{{ tags.length }} tags</template>
|
||||
<template v-else>No results</template>
|
||||
</div>
|
||||
<div v-if="!isLoading" class="search-result-list">
|
||||
|
@ -24,6 +25,14 @@
|
|||
:in-thread="false"
|
||||
:key="post.id"
|
||||
></post>
|
||||
<router-link
|
||||
class="search-result tag"
|
||||
v-for="tag in tags"
|
||||
:key="tag.name"
|
||||
:to="{ name: 'tag', params: { tagName: tag.name } }"
|
||||
>
|
||||
#{{ tag.name }}
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
</sidebar-layout>
|
||||
|
@ -34,7 +43,7 @@ import { onMounted } from "vue"
|
|||
import { $ref } from "vue/macros"
|
||||
import { useRoute } from "vue-router"
|
||||
|
||||
import { Post as PostObject } from "@/api/posts"
|
||||
import { Post as PostObject, Tag } from "@/api/posts"
|
||||
import { getSearchResults } from "@/api/search"
|
||||
import { Profile } from "@/api/users"
|
||||
import Loader from "@/components/Loader.vue"
|
||||
|
@ -52,6 +61,7 @@ let errorMessage = $ref("")
|
|||
|
||||
let profiles = $ref<Profile[]>([])
|
||||
let posts = $ref<PostObject[]>([])
|
||||
let tags = $ref<Tag[]>([])
|
||||
|
||||
onMounted(async () => {
|
||||
const q = route.query?.q
|
||||
|
@ -65,6 +75,7 @@ onMounted(async () => {
|
|||
)
|
||||
profiles = results.accounts
|
||||
posts = results.statuses
|
||||
tags = results.hashtags
|
||||
} catch (error: any) {
|
||||
errorMessage = error.message
|
||||
}
|
||||
|
@ -104,4 +115,8 @@ onMounted(async () => {
|
|||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.tag {
|
||||
padding: $block-inner-padding;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in a new issue