feed.hasNextPage && feed.fetchNextPage()}
@@ -309,16 +312,20 @@ export const HomeFeed: React.FC<{
data={feed.data?.pages}
itemContent={(_, posts) => {
if (!posts?.list.length) return
- return posts?.list.map((post) => {
- return (
-
- )
- })
+ return (
+
+ {posts?.list.map((post) => {
+ return (
+
+ )
+ })}
+
+ )
}}
>
diff --git a/src/models/home.model.ts b/src/models/home.model.ts
index 43e1d9a3..e62c96a4 100644
--- a/src/models/home.model.ts
+++ b/src/models/home.model.ts
@@ -8,7 +8,13 @@ import { ExpandedNote } from "~/lib/types"
import filter from "../../data/filter.json"
-export type FeedType = "latest" | "following" | "topic" | "hot" | "search"
+export type FeedType =
+ | "latest"
+ | "following"
+ | "topic"
+ | "hot"
+ | "search"
+ | "tag"
export type SearchType = "latest" | "hot"
export async function getFeed({
@@ -20,6 +26,7 @@ export async function getFeed({
daysInterval,
searchKeyword,
searchType,
+ tag,
}: {
type?: FeedType
cursor?: string
@@ -29,6 +36,7 @@ export async function getFeed({
daysInterval?: number
searchKeyword?: string
searchType?: SearchType
+ tag?: string
}) {
if (type === "search" && !searchKeyword) {
type = "latest"
@@ -258,6 +266,41 @@ export async function getFeed({
}),
)
+ return {
+ list,
+ cursor: result.cursor,
+ count: result.count,
+ }
+ }
+ case "tag": {
+ if (!tag) {
+ return {
+ list: [],
+ cursor: "",
+ count: 0,
+ }
+ }
+
+ let result = await indexer.getNotes({
+ sources: "xlog",
+ tags: ["post", tag],
+ limit,
+ cursor,
+ includeCharacter: true,
+ })
+
+ result.list = result.list.filter(
+ (note) => !filter.latest.includes(note.characterId),
+ )
+
+ const list = await Promise.all(
+ result.list.map(async (page: any) => {
+ const expand = await expandCrossbellNote(page, false, true)
+ delete expand.metadata?.content.content
+ return expand
+ }),
+ )
+
return {
list,
cursor: result.cursor,
diff --git a/src/queries/home.ts b/src/queries/home.ts
index 480ff5fb..59033273 100644
--- a/src/queries/home.ts
+++ b/src/queries/home.ts
@@ -12,6 +12,7 @@ export const useGetFeed = (data?: {
daysInterval?: number
searchKeyword?: string
searchType?: homeModel.SearchType
+ tag?: string
}) => {
return useInfiniteQuery({
queryKey: ["getFeed", data],