add "(series)" if post is a series home
This commit is contained in:
parent
b394d348ba
commit
9555f8d693
1 changed files with 15 additions and 14 deletions
|
@ -45,48 +45,49 @@ const StyledMetaContainer = styled.small`
|
||||||
})};
|
})};
|
||||||
`
|
`
|
||||||
|
|
||||||
interface _PostDateBase extends PostData {
|
interface PostCardData extends PostData {
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
postData: _PostDateBase
|
postData: PostCardData
|
||||||
}
|
}
|
||||||
|
|
||||||
const PostCard = (props: Props) => {
|
const PostCard = (props: Props) => {
|
||||||
|
const { postData } = props
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledPostCard
|
<StyledPostCard
|
||||||
onClick={() => navigate(process.env.PUBLIC_URL + props.postData.url)}
|
onClick={() => navigate(process.env.PUBLIC_URL + postData.url)}
|
||||||
>
|
>
|
||||||
<StyledTitle>{props.postData?.title || "No title"}</StyledTitle>
|
<StyledTitle>
|
||||||
|
{postData?.title || "No title"}
|
||||||
|
{/* show (series for regex matching "/series/<series-title>") */}
|
||||||
|
{/\/series\/[^/]*$/.test(postData.url) && " (series)"}
|
||||||
|
</StyledTitle>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<StyledMetaContainer>
|
<StyledMetaContainer>
|
||||||
<TagList direction="left">
|
<TagList direction="left">
|
||||||
{props.postData.tags &&
|
{postData.tags &&
|
||||||
props.postData.tags.map((tag) => {
|
postData.tags.map((tag) => {
|
||||||
return <Tag key={props.postData.title + tag} text={tag} />
|
return <Tag key={postData.title + tag} text={tag} />
|
||||||
})}
|
})}
|
||||||
</TagList>
|
</TagList>
|
||||||
<hr />
|
<hr />
|
||||||
<FontAwesomeIcon icon={faCalendar} />
|
<FontAwesomeIcon icon={faCalendar} />
|
||||||
|
|
||||||
{props.postData?.date || "Unknown date"}
|
{postData?.date || "Unknown date"}
|
||||||
|
|
||||||
<FontAwesomeIcon icon={faHourglass} />
|
<FontAwesomeIcon icon={faHourglass} />
|
||||||
|
|
||||||
{props.postData?.readTime
|
{postData?.readTime ? postData.readTime + " read" : "unknown length"}
|
||||||
? props.postData.readTime + " read"
|
|
||||||
: "unknown length"}
|
|
||||||
|
|
||||||
<FontAwesomeIcon icon={faBook} />
|
<FontAwesomeIcon icon={faBook} />
|
||||||
|
|
||||||
{props.postData?.wordCount
|
{postData?.wordCount ? postData.wordCount + " words" : "unknown words"}
|
||||||
? props.postData.wordCount + " words"
|
|
||||||
: "unknown words"}
|
|
||||||
</StyledMetaContainer>
|
</StyledMetaContainer>
|
||||||
</StyledPostCard>
|
</StyledPostCard>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue