From b7b31494c31d812af11048699c8b837781690ad5 Mon Sep 17 00:00:00 2001 From: Steven Tey Date: Thu, 25 Apr 2024 14:23:03 +0300 Subject: [PATCH] Fetch and display README content --- app/projects/[slug]/[[...tab]]/page.tsx | 25 +- app/projects/[slug]/layout.tsx | 22 +- .../projects/project-analytics-client.tsx | 5 +- components/projects/project-analytics.tsx | 11 +- .../projects/project-content-wrapper.tsx | 20 + components/projects/project-layout-tabs.tsx | 2 +- components/projects/project-readme.tsx | 15 + components/projects/project-tab-note.tsx | 17 +- components/projects/project-team.tsx | 5 +- components/ui/react-markdown.tsx | 79 ++++ lib/actions/get-project.ts | 27 ++ lib/github.ts | 2 + lib/types.ts | 1 + package.json | 5 + pnpm-lock.yaml | 374 ++++++++++++++++++ 15 files changed, 560 insertions(+), 50 deletions(-) create mode 100644 components/projects/project-content-wrapper.tsx create mode 100644 components/projects/project-readme.tsx create mode 100644 components/ui/react-markdown.tsx diff --git a/app/projects/[slug]/[[...tab]]/page.tsx b/app/projects/[slug]/[[...tab]]/page.tsx index 39c2403..4be8247 100644 --- a/app/projects/[slug]/[[...tab]]/page.tsx +++ b/app/projects/[slug]/[[...tab]]/page.tsx @@ -1,5 +1,7 @@ import ProjectAnalytics from "@/components/projects/project-analytics"; import { PROJECT_TABS } from "@/components/projects/project-constants"; +import ProjectContentWrapper from "@/components/projects/project-content-wrapper"; +import ProjectReadme from "@/components/projects/project-readme"; import ProjectTeam from "@/components/projects/project-team"; import { getProject } from "@/lib/actions/get-project"; import { notFound } from "next/navigation"; @@ -30,7 +32,12 @@ export default async function Project({ } if (!tab) { - return ; + return ( +
+ + {project.readme && } +
+ ); } if (tab[0] === "team") { @@ -39,13 +46,15 @@ export default async function Project({ if (tab[0] === "contributors") { return ( - - - + + + + + ); } } diff --git a/app/projects/[slug]/layout.tsx b/app/projects/[slug]/layout.tsx index 6a07dfb..3fcbca9 100644 --- a/app/projects/[slug]/layout.tsx +++ b/app/projects/[slug]/layout.tsx @@ -4,7 +4,6 @@ import ProjectLayoutTabs from "@/components/projects/project-layout-tabs"; import ProjectProvider from "@/components/projects/project-provider"; import { buttonLinkVariants } from "@/components/ui/button-link"; import { getProject } from "@/lib/actions/get-project"; -import { getRepo } from "@/lib/github"; import prisma from "@/lib/prisma"; import { constructMetadata } from "@/lib/utils"; import { cn, nFormatter } from "@dub/utils"; @@ -57,19 +56,6 @@ export default async function ProjectLayout({ notFound(); } - const { stars } = await getRepo(project.githubLink.url); - - if (stars !== project.stars) { - await prisma.project.update({ - where: { - slug, - }, - data: { - stars, - }, - }); - } - return (
-

{nFormatter(stars, { full: true })}

+

+ {nFormatter(project.stars, { full: true })} +

{project.websiteLink && ( -
- {children} -
+ {children} ); } diff --git a/components/projects/project-analytics-client.tsx b/components/projects/project-analytics-client.tsx index 711b2cb..8bb6161 100644 --- a/components/projects/project-analytics-client.tsx +++ b/components/projects/project-analytics-client.tsx @@ -32,7 +32,10 @@ export default function ProjectAnalyticsClient({ return (
-
+
+

+ Real-time click analytics +