File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
src/app/[username]/[articleHandle] Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ import ReactionStatus from "@/components/render-props/ReactionStatus" ;
4+ import clsx from "clsx" ;
5+ import React from "react" ;
6+
7+ interface Props {
8+ article_id : string ;
9+ }
10+
11+ const ArticleReaction : React . FC < Props > = ( { article_id } ) => {
12+ return (
13+ < ReactionStatus
14+ resource_type = "ARTICLE"
15+ resource_id = { article_id }
16+ render = { ( { reactions, toggle } ) => {
17+ return (
18+ < div className = "flex gap-1" >
19+ { reactions . map ( ( r ) => (
20+ < button
21+ className = { clsx (
22+ "px-2 py-1 flex gap-1 cursor-pointer rounded-sm hover:bg-primary/20" ,
23+ { "bg-primary/20" : r . is_reacted }
24+ ) }
25+ onClick = { ( ) => toggle ( r . reaction_type ! ) }
26+ >
27+ < img
28+ src = { `/reactions/${ r . reaction_type } .svg` }
29+ alt = { `reaction-${ article_id } -${ r . reaction_type } ` }
30+ className = "size-5 flex-none"
31+ />
32+ < span > { r . count } </ span >
33+ </ button >
34+ ) ) }
35+ </ div >
36+ ) ;
37+ } }
38+ />
39+ ) ;
40+ } ;
41+
42+ export default ArticleReaction ;
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ import { notFound } from "next/navigation";
1313import type { Article , WithContext } from "schema-dts" ;
1414import { eq } from "sqlkit" ;
1515import ArticleSidebar from "./_components/ArticleSidebar" ;
16+ import ReactionStatus from "@/components/render-props/ReactionStatus" ;
17+ import clsx from "clsx" ;
18+ import ArticleReaction from "./_components/ArticleReaction" ;
1619
1720interface ArticlePageProps {
1821 params : Promise < {
@@ -150,6 +153,8 @@ const Page: NextPage<ArticlePageProps> = async ({ params }) => {
150153 < h1 className = "text-2xl font-bold" > { article ?. title ?? "" } </ h1 >
151154 </ div >
152155
156+ < ArticleReaction article_id = { article . id } />
157+
153158 < div className = "mx-auto content-typography" > { parsedHTML } </ div >
154159 </ div >
155160 </ HomepageLayout >
You can’t perform that action at this time.
0 commit comments