@@ -2,6 +2,7 @@ import Link from 'next/link'
22import { useContext } from 'react'
33import { FormattedMessage } from 'react-intl'
44
5+ import IconBook2 from '@/public/static/icons/24px/book2.svg'
56import IconPaywall from '@/public/static/icons/24px/paywall.svg'
67import IconStar from '@/public/static/icons/24px/star.svg'
78import { toPath } from '~/common/utils'
@@ -29,6 +30,7 @@ export type FooterActionsProps = {
2930 hasDonationCount ?: boolean
3031 hasCircle ?: boolean
3132 hasCampaign ?: boolean
33+ hasCollection ?: boolean
3234 tag ?: React . ReactNode
3335 includesMetaData ?: boolean
3436} & FooterActionsControls
@@ -40,6 +42,7 @@ const FooterActions = ({
4042 hasDonationCount,
4143 hasCircle,
4244 hasCampaign = true ,
45+ hasCollection = false ,
4346 tag,
4447 includesMetaData = true ,
4548 ...controls
@@ -50,6 +53,18 @@ const FooterActions = ({
5053 const viewer = useContext ( ViewerContext )
5154 const { lang } = useContext ( LanguageContext )
5255 const { channelId, pinned, hasTogglePinChannelArticles } = controls
56+ const collection = article . collections . edges
57+ ?. map ( ( edge ) => edge . node )
58+ . reduce (
59+ ( maxCollection , currentCollection ) => {
60+ if ( ! maxCollection ) return currentCollection
61+ return currentCollection . articles . totalCount >
62+ maxCollection . articles . totalCount
63+ ? currentCollection
64+ : maxCollection
65+ } ,
66+ null as ( typeof article . collections . edges ) [ 0 ] [ 'node' ] | null
67+ )
5368
5469 return (
5570 < footer className = { styles . footer } >
@@ -112,6 +127,25 @@ const FooterActions = ({
112127 }
113128 </ Link >
114129 ) }
130+
131+ { hasCollection && collection && article . author . userName && (
132+ < Link
133+ { ...toPath ( {
134+ page : 'collectionDetail' ,
135+ userName : article . author . userName ,
136+ collection,
137+ } ) }
138+ className = { styles . collection }
139+ >
140+ < TextIcon
141+ icon = { < Icon icon = { IconBook2 } size = { 12 } /> }
142+ size = { 12 }
143+ color = "newPalettePrimary500"
144+ >
145+ { collection . title }
146+ </ TextIcon >
147+ </ Link >
148+ ) }
115149 </ >
116150 ) }
117151 </ section >
0 commit comments