feat(bolg) add animation

This commit is contained in:
lumither committed 2024-06-06 19:13:25 +08:00
1 parent 56d673a9ec
commit c62fe7d1ef
6 files changed
+32 -18

No files matched your search

+2 -5
View File
@@ -1,7 +1,7 @@
import React from 'react';
import { Card, CardBody, CardFooter } from '@nextui-org/card';
import { Chip, Image } from '@nextui-org/react';
import NextImage from 'next/image';
import { Chip } from '@nextui-org/react';
import Image from 'next/image';
import Link from 'next/link';
import { MdCalendarMonth, MdNorthEast } from 'react-icons/md';
@@ -29,10 +29,8 @@ function BlogPostCard({ post }: Props) {
isHoverable
>
{ header_img !== '' && <div className={ `w-full overflow h-80 relative` }>
<Image
as={ NextImage }
alt={ 'cover picture' }
src={ header_img }
className={ `w-full object-cover rounded-b-none` }
@@ -41,7 +39,6 @@ function BlogPostCard({ post }: Props) {
'backdropFilter': 'blur(20px)'
} }
fill
removeWrapper
></Image>
</div> }
+9 -2
View File
@@ -2,6 +2,7 @@ import React from 'react';
import fetch_posts_list from '@/app/blog/fetch_posts_list';
import BlogPostCard from '@/app/blog/BlogPostCard';
import { Card, CardBody } from '@nextui-org/card';
import { MotionDiv } from '@/app/public/MotionDiv';
async function Blog() {
@@ -11,9 +12,15 @@ async function Blog() {
return (
// blog list
<ul className={ 'flex flex-col items-center w-full space-y-7' }>
{ posts.map((post: JSON, key: React.Key | null | undefined) => (
{ posts.map((post: JSON, key: number) => (
<li key={ key } className={ 'w-full' }>
<BlogPostCard post={ post } />
<MotionDiv
initial={ { y: 20, opacity: 0 } }
animate={ { y: 0, opacity: 1 } }
transition={ { ease: 'easeInOut', duration: 0.5, delay: key * .2 + .25 } }
>
<BlogPostCard post={ post } />
</MotionDiv>
</li>)
) }
</ul>
+10 -3
View File
@@ -1,12 +1,19 @@
import React from 'react';
import Generate from '@/app/blog/post/[id]/generate';
import { MotionDiv } from '@/app/public/MotionDiv';
function BlogReader({ params }: { params: { id: string } }) {
return (
<div className={ `w-full` }>
<Generate id={ params.id } />
</div>
<MotionDiv
initial={ { y: 20, opacity: 0 } }
animate={ { y: 0, opacity: 1 } }
transition={ { ease: 'easeInOut', duration: 0.5 } }
>
<div className={ `w-full` }>
<Generate id={ params.id } />
</div>
</MotionDiv>
);
}
+5
View File
@@ -0,0 +1,5 @@
'use client';
import { motion } from 'framer-motion';
export const MotionDiv = motion.div;