moved everything out of the source
directory
This commit is contained in:
parent
8f13b81918
commit
294387d8d5
151 changed files with 21 additions and 60 deletions
97
src/components/PostCard.tsx
Normal file
97
src/components/PostCard.tsx
Normal file
|
@ -0,0 +1,97 @@
|
|||
import styled from "styled-components"
|
||||
import { Link } from "react-router-dom"
|
||||
|
||||
import { PostData } from "../../types/types"
|
||||
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||
import {
|
||||
faBook,
|
||||
faCalendar,
|
||||
faHourglass,
|
||||
} from "@fortawesome/free-solid-svg-icons"
|
||||
|
||||
import Tag from "./Tag"
|
||||
import TagList from "./TagList"
|
||||
import MainContent from "./MainContent"
|
||||
|
||||
import theming from "../styles/theming"
|
||||
|
||||
const StyledPostCard = styled(MainContent)`
|
||||
box-shadow: 0 4px 10px rgb(0 0 0 / 10%);
|
||||
text-align: left;
|
||||
margin-bottom: 2rem;
|
||||
|
||||
color: ${(props) =>
|
||||
theming.theme(props.theme.currentTheme, {
|
||||
light: theming.light.color1,
|
||||
dark: theming.dark.color1,
|
||||
})};
|
||||
|
||||
${theming.styles.hoverCard}
|
||||
`
|
||||
|
||||
const StyledTitle = styled.h1`
|
||||
font-size: 2rem;
|
||||
font-style: bold;
|
||||
margin: 0;
|
||||
margin-bottom: 1rem;
|
||||
`
|
||||
|
||||
const StyledMetaContainer = styled.small`
|
||||
color: ${(props) =>
|
||||
theming.theme(props.theme.currentTheme, {
|
||||
light: theming.light.color2,
|
||||
dark: theming.dark.color2,
|
||||
})};
|
||||
`
|
||||
|
||||
interface PostCardData extends PostData {
|
||||
url: string
|
||||
}
|
||||
|
||||
interface Props {
|
||||
postData: PostCardData
|
||||
}
|
||||
|
||||
const PostCard = (props: Props) => {
|
||||
const { postData } = props
|
||||
|
||||
return (
|
||||
<Link to={process.env.PUBLIC_URL + postData.url}>
|
||||
<StyledPostCard>
|
||||
<StyledTitle>
|
||||
{postData?.title || "No title"}
|
||||
{/* show (series for regex matching "/series/<series-title>") */}
|
||||
{/\/series\/[^/]*$/.test(postData.url) && " (series)"}
|
||||
</StyledTitle>
|
||||
|
||||
<br />
|
||||
|
||||
<StyledMetaContainer>
|
||||
<TagList direction="left">
|
||||
{postData.tags &&
|
||||
postData.tags.map((tag) => {
|
||||
return <Tag key={postData.title + tag} text={tag} />
|
||||
})}
|
||||
</TagList>
|
||||
<hr />
|
||||
<FontAwesomeIcon icon={faCalendar} />
|
||||
|
||||
{postData?.date || "Unknown date"}
|
||||
|
||||
<FontAwesomeIcon icon={faHourglass} />
|
||||
|
||||
{postData?.readTime ? postData.readTime + " read" : "unknown length"}
|
||||
|
||||
<FontAwesomeIcon icon={faBook} />
|
||||
|
||||
{postData?.wordCount
|
||||
? postData.wordCount + " words"
|
||||
: "unknown words"}
|
||||
</StyledMetaContainer>
|
||||
</StyledPostCard>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
export default PostCard
|
Loading…
Add table
Add a link
Reference in a new issue