From d16981c2b5e07c54198359f04e1eae4054e8f7cf Mon Sep 17 00:00:00 2001 From: silverpill Date: Mon, 19 Sep 2022 01:02:14 +0000 Subject: [PATCH] Enable hashtag search --- src/api/posts.ts | 4 ++-- src/api/search.ts | 3 ++- src/views/SearchResultList.vue | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/api/posts.ts b/src/api/posts.ts index ad49904..1857a1e 100644 --- a/src/api/posts.ts +++ b/src/api/posts.ts @@ -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; diff --git a/src/api/search.ts b/src/api/search.ts index ead8870..d93351f 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -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( diff --git a/src/views/SearchResultList.vue b/src/views/SearchResultList.vue index b359a60..e13592c 100644 --- a/src/views/SearchResultList.vue +++ b/src/views/SearchResultList.vue @@ -6,6 +6,7 @@ +
@@ -24,6 +25,14 @@ :in-thread="false" :key="post.id" > + + #{{ tag.name }} +
@@ -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([]) let posts = $ref([]) +let tags = $ref([]) 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; +}