From 95a4b9aa0a79b3fa94946db9185a327c0c35f10d Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 3 Jul 2023 21:36:19 +0100 Subject: [PATCH] feat: topics in home tab --- data/topics.json | 56 +++++++++++++++++++ .../{ => (activities)}/topic/[topic]/page.tsx | 21 ++++--- src/components/home/HomeActivitiesTabs.tsx | 11 +++- src/components/home/HomeFeed.tsx | 1 + src/components/home/HomeSidebar.tsx | 21 ------- src/components/ui/Tabs.tsx | 2 +- src/lib/i18n/locales/zh/index.json | 5 +- 7 files changed, 84 insertions(+), 33 deletions(-) rename src/app/(home)/{ => (activities)}/topic/[topic]/page.tsx (56%) diff --git a/data/topics.json b/data/topics.json index c2b528ca..2202d2df 100644 --- a/data/topics.json +++ b/data/topics.json @@ -2,13 +2,39 @@ { "name": "xLog", "description": "Let's talk about xLog, whether to praise or criticize it.", + "includeTags": [ + "xLog" + ], "includeKeywords": [ "xLog" ] }, + { + "name": "Web3", + "includeTags": [ + "Web3" + ], + "includeKeywords": [ + "Web3", + "Blockchain", + "NFT", + "DeFi", + "DAO", + "DApp", + "区块链", + "區塊鏈", + "加密货币", + "DeGame", + "链游", + "Crypto" + ] + }, { "name": "Artificial Intelligence", "description": "The world is undergoing changes, and we are at the center of it.", + "includeTags": [ + "AI" + ], "includeKeywords": [ "GPT", "Midjourney", @@ -20,6 +46,10 @@ { "name": "Life Journal", "description": "Discover new perspectives and insights in others' weekly, monthly, or yearly journal.", + "includeTags": [ + "Life", + "生活" + ], "includeKeywords": [ "Review", "Weekly", @@ -33,6 +63,10 @@ { "name": "Fiction", "description": "Experience a world of imagination through these fiction stories.", + "includeTags": [ + "Fiction", + "小说" + ], "notes": [ "51124-60", "53766-19", @@ -79,5 +113,27 @@ "48910-11", "51124-31" ] + }, + { + "name": "Coding", + "includeTags": [ + "Coding", + "编程" + ], + "includeKeywords": [ + "Coding", + "编程", + "JavaScript", + "Python", + "Java", + "前端", + "源码", + "Linux", + "Ubuntu", + "React", + "Vue", + "服务器", + "Docker" + ] } ] diff --git a/src/app/(home)/topic/[topic]/page.tsx b/src/app/(home)/(activities)/topic/[topic]/page.tsx similarity index 56% rename from src/app/(home)/topic/[topic]/page.tsx rename to src/app/(home)/(activities)/topic/[topic]/page.tsx index f3f0fa55..9702021c 100644 --- a/src/app/(home)/topic/[topic]/page.tsx +++ b/src/app/(home)/(activities)/topic/[topic]/page.tsx @@ -1,11 +1,11 @@ import { Metadata } from "next" import { HomeFeed } from "~/components/home/HomeFeed" -import { HomeSidebar } from "~/components/home/HomeSidebar" +import { Button } from "~/components/ui/Button" import { APP_NAME } from "~/lib/env" import { useTranslation } from "~/lib/i18n" -import topics from "../../../../../data/topics.json" +import topics from "../../../../../../data/topics.json" export function generateMetadata({ params, @@ -33,17 +33,22 @@ export default async function Topic({ return ( <> -
-

{t(params.topic)}

-

{t(info?.description || "")}

+
+
+ + {info?.includeTags[0]} +
+

{t(info?.description || "")}

{info?.includeKeywords?.length || 0 > 0 ? ( -

+

{t("Topic Keywords")}: {info?.includeKeywords?.join(", ")}

) : null} - +
- + ) } diff --git a/src/components/home/HomeActivitiesTabs.tsx b/src/components/home/HomeActivitiesTabs.tsx index 007725f9..329cba12 100644 --- a/src/components/home/HomeActivitiesTabs.tsx +++ b/src/components/home/HomeActivitiesTabs.tsx @@ -7,11 +7,13 @@ import { useAccountState, useConnectModal } from "@crossbell/connect-kit" import { Tabs } from "~/components/ui/Tabs" import { useTranslation } from "~/lib/i18n/client" +import topics from "../../../data/topics.json" + export const HomeActivitiesTabs = () => { const pathname = usePathname() const connectModal = useConnectModal() const router = useRouter() - const { t, i18n } = useTranslation("index") + const { t } = useTranslation("index") const currentCharacterId = useAccountState( (s) => s.computed.account?.characterId, @@ -39,7 +41,12 @@ export const HomeActivitiesTabs = () => { }, active: pathname === "/following", }, + ...topics.map((topic) => ({ + text: t(topic.name), + href: `/topic/${encodeURIComponent(topic.name)}`, + active: pathname === `/topic/${encodeURIComponent(topic.name)}`, + })), ] - return + return } diff --git a/src/components/home/HomeFeed.tsx b/src/components/home/HomeFeed.tsx index 8c3c18c3..3e358c84 100644 --- a/src/components/home/HomeFeed.tsx +++ b/src/components/home/HomeFeed.tsx @@ -373,6 +373,7 @@ export const HomeFeed = ({ listClassName="grid gap-3 sm:gap-6 grid-cols-2 sm:grid-cols-3" itemContent={(index) => { const post = feedInOne[index] + if (!post) return null return ( {!hideSearch && } -
-
-

{t("Hot Topics")}

-
    - {topics.map((topic: any) => ( -
  • - - {t(topic.name)} - - {t(topic.description)} - - -
  • - ))} -
-
-

{t("Suggested creators for you")}

diff --git a/src/components/ui/Tabs.tsx b/src/components/ui/Tabs.tsx index b66e9422..1d7564d9 100644 --- a/src/components/ui/Tabs.tsx +++ b/src/components/ui/Tabs.tsx @@ -27,8 +27,8 @@ export const Tabs = ({ return (
{items.map((item) => { diff --git a/src/lib/i18n/locales/zh/index.json b/src/lib/i18n/locales/zh/index.json index 82e6a473..a4415b05 100644 --- a/src/lib/i18n/locales/zh/index.json +++ b/src/lib/i18n/locales/zh/index.json @@ -60,11 +60,14 @@ "Suggested creators for you": "为你推荐的创作者", "Hot Topics": "热门话题", "Topic Keywords" : "话题关键词", + "Topic Tags": "话题标签", "Let's talk about xLog, whether to praise or criticize it." : "让我们来谈谈 xLog,无论赞美和批评。", "Artificial Intelligence": "人工智能", "The world is undergoing changes, and we are at the center of it.": "世界正在发生变革,而我们正处其中心。", "Life Journal": "生活日记", "Discover new perspectives and insights in others' weekly, monthly, or yearly journal.": "在别人的周月年记中发现新观点和见解。", "Fiction": "虚构小说", - "Experience a world of imagination through these fiction stories." : "体验一个充满想象力的虚构世界。" + "Experience a world of imagination through these fiction stories." : "体验一个充满想象力的虚构世界。", + "Coding": "编程", + "Participate in Topic": "参与话题" } \ No newline at end of file