diff --git a/src/app/site/[site]/page.tsx b/src/app/site/[site]/page.tsx index d9ade289a5..80a8a6c0a5 100644 --- a/src/app/site/[site]/page.tsx +++ b/src/app/site/[site]/page.tsx @@ -1,9 +1,13 @@ import { Hydrate, dehydrate } from "@tanstack/react-query" +import ShortPreviewList from "~/components/site/ShortPreviewList" import SiteHome from "~/components/site/SiteHome" import getQueryClient from "~/lib/query-client" import { PageVisibilityEnum } from "~/lib/types" -import { prefetchGetPagesBySite } from "~/queries/page.server" +import { + fetchGetPagesBySite, + prefetchGetPagesBySite, +} from "~/queries/page.server" import { fetchGetSite } from "~/queries/site.server" async function SiteIndexPage({ @@ -26,13 +30,26 @@ async function SiteIndexPage({ }, queryClient, ) + const shorts = await fetchGetPagesBySite( + { + characterId: site?.characterId, + type: "short", + visibility: PageVisibilityEnum.Published, + useStat: true, + limit: 8, + }, + queryClient, + ) const dehydratedState = dehydrate(queryClient) return ( - - - +
+ {!!shorts?.count && } + + + +
) } diff --git a/src/components/site/ShortPreviewList.tsx b/src/components/site/ShortPreviewList.tsx new file mode 100644 index 0000000000..67a32a3dc4 --- /dev/null +++ b/src/components/site/ShortPreviewList.tsx @@ -0,0 +1,66 @@ +import Link from "next/link" + +import { Image } from "~/components/ui/Image" +import { Tooltip } from "~/components/ui/Tooltip" +import { ExpandedNote } from "~/lib/types" +import { cn } from "~/lib/utils" + +export default function ShortList({ + shorts, +}: { + shorts: { + list: ExpandedNote[] + count: number + cursor: string | null + } +}) { + if (!shorts) return null + + return ( + <> +
+ {shorts.list.map((post) => ( + + + cover + + + ))} + + + + + +
+ + ) +}