From 57446671b7d5b1123ab26e5caab0771cf36e10a0 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 4 Aug 2023 23:20:46 +0100 Subject: [PATCH] feat: portfolio in archives page --- src/app/site/[site]/archives/page.tsx | 2 +- src/components/common/PostCard.tsx | 9 +++------ src/components/site/SiteArchives.tsx | 17 +++++++++++------ src/lib/i18n/locales/zh/common.json | 3 ++- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/app/site/[site]/archives/page.tsx b/src/app/site/[site]/archives/page.tsx index b65b837a..3de33df6 100644 --- a/src/app/site/[site]/archives/page.tsx +++ b/src/app/site/[site]/archives/page.tsx @@ -39,7 +39,7 @@ export default async function SiteArchivesPage({ await prefetchGetPagesBySite( { characterId: site?.characterId, - type: "post", + type: ["post", "portfolio"], visibility: PageVisibilityEnum.Published, limit: 100, skipExpansion: true, diff --git a/src/components/common/PostCard.tsx b/src/components/common/PostCard.tsx index ca884b26..df4494e4 100644 --- a/src/components/common/PostCard.tsx +++ b/src/components/common/PostCard.tsx @@ -118,19 +118,16 @@ const Card = ({ label={`${platform?.name || platform}`} className="text-sm" > - - {platform?.icon ? ( + + {platform?.icon && ( {platform?.name} - ) : ( - - - )} + {t("Portfolio")} diff --git a/src/components/site/SiteArchives.tsx b/src/components/site/SiteArchives.tsx index 547e3095..9b5a3d1d 100644 --- a/src/components/site/SiteArchives.tsx +++ b/src/components/site/SiteArchives.tsx @@ -1,6 +1,5 @@ "use client" -import Link from "next/link" import { useParams, usePathname } from "next/navigation" import { useMemo } from "react" @@ -30,7 +29,7 @@ export const SiteArchives = () => { const site = useGetSite(params?.site as string) const posts = useGetPagesBySiteLite({ characterId: site.data?.characterId, - type: "post", + type: ["post", "portfolio"], visibility: PageVisibilityEnum.Published, limit: 100, skipExpansion: true, @@ -63,7 +62,7 @@ export const SiteArchives = () => { if (posts.data?.pages?.length) { for (const page of posts.data.pages) { for (const post of page.list) { - post.metadata?.content?.tags?.forEach((tag) => { + post.metadata?.content?.tags?.forEach((tag: string) => { if (!RESERVED_TAGS.includes(tag)) { if (result.has(tag)) { result.set(tag, result.get(tag) + 1) @@ -124,12 +123,18 @@ export const SiteArchives = () => { {posts.map((post) => { currentLength++ + const isPortfolio = + post.metadata?.content?.tags?.[0] === "portfolio" + const externalLink = + post.metadata?.content?.external_urls?.[0] || "" return ( - @@ -149,7 +154,7 @@ export const SiteArchives = () => { }, })} - + ) })} diff --git a/src/lib/i18n/locales/zh/common.json b/src/lib/i18n/locales/zh/common.json index bccc9232..9e65444c 100644 --- a/src/lib/i18n/locales/zh/common.json +++ b/src/lib/i18n/locales/zh/common.json @@ -100,5 +100,6 @@ "Pinned": "置顶", "Blockchain ID": "区块链标识", "Confirmed by {{blockNumber}} blocks": "已被 {{blockNumber}} 个区块确认", - "Current Block Height": "当前区块高度" + "Current Block Height": "当前区块高度", + "Portfolio": "作品" }