diff --git a/src/pages/Blog/Blog.tsx b/src/pages/Blog/Blog.tsx index 61dc08c..27ee8d3 100644 --- a/src/pages/Blog/Blog.tsx +++ b/src/pages/Blog/Blog.tsx @@ -7,8 +7,10 @@ import Markdown from 'react-markdown'; import { service } from '@services/axiosConfig'; import { Issue, Item } from '../../models/issue.interface'; import { formatDistanceToNow } from 'date-fns'; +import { useNavigation } from 'react-router-dom'; export function Blog() { + const navigation = useNavigation(); const { data } = useQuery('posts', async () => { const res = (await service.get('/search/issues?q=repo:davidrock/github-blog')).data; @@ -16,6 +18,10 @@ export function Blog() { return res; }); + function handlePostClick(){ + navigation + } + return (
diff --git a/src/pages/Post/Post.tsx b/src/pages/Post/Post.tsx index 9b10492..6c4c8d6 100644 --- a/src/pages/Post/Post.tsx +++ b/src/pages/Post/Post.tsx @@ -1,7 +1,19 @@ -export function Post() { +import { BlogHeader } from '@pages/Blog'; +import Scrollbars from 'rc-scrollbars'; +import { Item } from '../../models/issue.interface'; +import { Title } from './components/Title'; + +type PostProps = { + post?: Item; +}; + +export function Post({ post }: PostProps) { return ( - <> -

Post

- +
+ + +
{post && }</div> + </Scrollbars> + </div> ); } diff --git a/src/pages/Post/components/Title.tsx b/src/pages/Post/components/Title.tsx new file mode 100644 index 0000000..759cc6d --- /dev/null +++ b/src/pages/Post/components/Title.tsx @@ -0,0 +1,42 @@ +import { FaGithub, FaUserGroup, FaArrowUpRightFromSquare, FaCalendar, FaChevronLeft } from 'react-icons/fa6'; +import { Item } from '../../../models/issue.interface'; +import { formatDistanceToNow } from 'date-fns'; + +type ItemProps = { + post: Item; +}; + +export function Title({ post }: ItemProps) { + return ( + <div className="flex gap-10 bg-base-profile py-8 px-10 rounded-2xl drop-shadow-lg"> + <div className="flex"> + <div className="absolute right-10 flex flex-row text-xs"> + <a href="https://github.com/davidrock" className="flex items-center gap-2"> + Back + <FaArrowUpRightFromSquare width={12} height={12} /> + </a> + </div> + <div className="absolute right-10 flex flex-row text-xs"> + <a href="https://github.com/davidrock" className="flex items-center gap-2"> + Go to Github + <FaChevronLeft width={12} height={12} /> + </a> + </div> + </div> + <div className="flex flex-col gap-2"> + <h1>{post?.title}</h1> + <div className="flex gap-6 items-center mt-4"> + <div className="flex items-center gap-2"> + <FaGithub /> {post?.user.login} + </div> + <div className="flex items-center gap-2"> + <FaCalendar /> {formatDistanceToNow(post.updated_at, { addSuffix: true })} + </div> + <div className="flex items-center gap-2"> + <FaUserGroup /> {post.comments} comments + </div> + </div> + </div> + </div> + ); +} diff --git a/src/routes.tsx b/src/routes.tsx index b74d32a..c28ad45 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -19,7 +19,7 @@ export const routes = createBrowserRouter([ errorElement: <MyFallbackComponent />, }, { - path: '/post', + path: '/github-blog/post', element: <Post />, errorElement: <MyFallbackComponent />, },