- increased text size a bit - removed unused css from kbd tag - removed unused white link css - added space before all headers except h1 - moved type decclaration files to one directory - replaced tag icon to hashtag - redesigned post card - removed unnecessary margin from post card titles - removed post card content preview - organized recursive parsing code
109 lines
2.3 KiB
TypeScript
109 lines
2.3 KiB
TypeScript
import styled from "styled-components"
|
|
import { useNavigate } from "react-router-dom"
|
|
|
|
import { PostData } from "../../types/typing"
|
|
|
|
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;
|
|
cursor: pointer;
|
|
|
|
color: ${(props) =>
|
|
theming.theme(props.theme.currentTheme, {
|
|
light: theming.light.color1,
|
|
dark: theming.dark.color1,
|
|
})};
|
|
|
|
&:hover {
|
|
box-shadow: ${(props) =>
|
|
theming.theme(props.theme.currentTheme, {
|
|
light: "0 4px 10px rgb(0 0 0 / 25%)",
|
|
dark: "0 4px 10px rgb(255 255 255 / 20%)",
|
|
})};
|
|
}
|
|
`
|
|
|
|
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: "#555",
|
|
dark: "#CCC",
|
|
})};
|
|
`
|
|
|
|
interface _PostDateBase extends PostData {
|
|
url: string
|
|
}
|
|
|
|
interface Props {
|
|
postData: _PostDateBase
|
|
}
|
|
|
|
const PostCard = (props: Props) => {
|
|
const navigate = useNavigate()
|
|
|
|
return (
|
|
<StyledPostCard
|
|
onClick={() =>
|
|
navigate(process.env.PUBLIC_URL + props.postData.url)
|
|
}
|
|
>
|
|
<StyledTitle>{props.postData?.title || "No title"}</StyledTitle>
|
|
|
|
<br />
|
|
|
|
<StyledMetaContainer>
|
|
<TagList direction="left">
|
|
{props.postData.tags &&
|
|
props.postData.tags.map((tag) => {
|
|
return (
|
|
<Tag
|
|
key={props.postData.title + tag}
|
|
text={tag}
|
|
/>
|
|
)
|
|
})}
|
|
</TagList>
|
|
<hr />
|
|
<FontAwesomeIcon icon={faCalendar} />
|
|
|
|
{props.postData?.date || "Unknown date"}
|
|
|
|
<FontAwesomeIcon icon={faHourglass} />
|
|
|
|
{props.postData?.readTime
|
|
? props.postData.readTime + " read"
|
|
: "unknown length"}
|
|
|
|
<FontAwesomeIcon icon={faBook} />
|
|
|
|
{props.postData?.wordCount
|
|
? props.postData.wordCount + " words"
|
|
: "unknown words"}
|
|
</StyledMetaContainer>
|
|
</StyledPostCard>
|
|
)
|
|
}
|
|
|
|
export default PostCard
|