mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(frontend/blog) better post card
This commit is contained in:
1 parent
85d474e902
commit
7e0b015cbc
1 file changed
+62
-14
+62
-14
@@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Card, CardBody, CardHeader } from '@nextui-org/card';
|
import { Card, CardBody, CardFooter } from '@nextui-org/card';
|
||||||
import { Divider } from '@nextui-org/react';
|
import { Chip, Image } from '@nextui-org/react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
import { MdCalendarMonth, MdNorthEast } from 'react-icons/md';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
post: JSON
|
post: JSON
|
||||||
@@ -9,25 +10,72 @@ type Props = {
|
|||||||
|
|
||||||
function BlogPostCard({ post }: Props) {
|
function BlogPostCard({ post }: Props) {
|
||||||
let title = (post as any)['title'];
|
let title = (post as any)['title'];
|
||||||
let summary = (post as any)['summary'];
|
let sub_title = (post as any)['sub_title'];
|
||||||
let last_update = (post as any)['last_update'];
|
// let summary = (post as any)['summary'];
|
||||||
|
let category = (post as any)['category'];
|
||||||
|
let tags = (post as any)['tags'];
|
||||||
|
// let last_update = new Date((post as any)['last_update']);
|
||||||
|
let first_update = new Date((post as any)['first_update']);
|
||||||
let post_id = (post as any)['post_id'];
|
let post_id = (post as any)['post_id'];
|
||||||
|
let pic_url = (post as any)['pic_url'];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Card as={ Link } href={ `/blog/post/${ post_id }` } className={ `mx-7` }>
|
<Card as={ Link } href={ `/blog/post/${ post_id }` }
|
||||||
<CardHeader>
|
className={ `mx-7` }
|
||||||
<p className={ 'font-bold' }>{ title }</p>
|
isPressable
|
||||||
</CardHeader>
|
isHoverable
|
||||||
<Divider />
|
>
|
||||||
|
{ pic_url !== '' && <div className={ `w-full overflow-visible` }>
|
||||||
|
<Image
|
||||||
|
// as={NextImage}
|
||||||
|
isZoomed
|
||||||
|
isBlurred
|
||||||
|
alt={ 'cover picture' }
|
||||||
|
src={ pic_url }
|
||||||
|
className={ `h-80 w-full object-cover` }
|
||||||
|
width={ `100%` }
|
||||||
|
// removeWrapper
|
||||||
|
></Image>
|
||||||
|
</div> }
|
||||||
|
|
||||||
<CardBody>
|
<CardBody>
|
||||||
{ summary }
|
<div className={ `flex flex-row justify-between` }>
|
||||||
</CardBody>
|
<div className={ `mx-2 mt-2` }>
|
||||||
<Divider />
|
<Chip className={ `mb-2` } radius={ `sm` } color={ `secondary` }
|
||||||
<CardBody>
|
variant={ `flat` }>{ category }</Chip>
|
||||||
{ last_update }
|
<p className={ `text-4xl font-bold` }> { title }</p>
|
||||||
|
<p className={ `text-xl` }> { sub_title }</p>
|
||||||
|
</div>
|
||||||
|
<MdNorthEast className={ `mt-4 mr-2` } size={ `40px` } />
|
||||||
|
</div>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
|
<CardFooter>
|
||||||
|
<div className={ `flex flex-row flex-wrap justify-between w-full` }>
|
||||||
|
<div>
|
||||||
|
<ul className={ `flex flex-row flex-wrap` }>
|
||||||
|
{
|
||||||
|
tags.map((tag: string, key: any) => (
|
||||||
|
<li key={ key } className={ `mx-1 mb-1` }>
|
||||||
|
<Chip>{ tag }</Chip>
|
||||||
|
</li>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div className={ `flex flex-row place-content-end mb-1 items-center mx-1` }>
|
||||||
|
<MdCalendarMonth />
|
||||||
|
<p className={ `text-zinc-500 dark:text-zinc-400 ml-1` }>
|
||||||
|
{ first_update.toLocaleString('default', {
|
||||||
|
month: `long`,
|
||||||
|
day: `numeric`,
|
||||||
|
year: `numeric`
|
||||||
|
}) }
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user