-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from zhuba-Ahhh/dev
refactor: ♻️ blog list拆分
- Loading branch information
Showing
28 changed files
with
345 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Link from "next/link"; | ||
import { motion } from "framer-motion"; | ||
import { | ||
Card, | ||
CardHeader, | ||
CardTitle, | ||
CardDescription, | ||
CardContent, | ||
CardFooter, | ||
Badge, | ||
} from "@/components/ui"; | ||
import { BlogPost } from "@/data/blogPosts"; | ||
|
||
interface BlogPostCardProps { | ||
post: BlogPost; | ||
onTagClick: (tag: string) => void; | ||
index: number; | ||
} | ||
|
||
const cardVariants = { | ||
hidden: { opacity: 0, y: -20 }, | ||
visible: { opacity: 1, y: 0 }, | ||
exit: { opacity: 0, y: 20 }, | ||
}; | ||
|
||
export function BlogPostCard({ post, onTagClick, index }: BlogPostCardProps) { | ||
return ( | ||
<motion.div | ||
variants={cardVariants} | ||
initial="hidden" | ||
animate="visible" | ||
exit="exit" | ||
transition={{ duration: 0.3, delay: index * 0.1 }} | ||
layout | ||
> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle> | ||
<Link href={`/blog/${post.id}`}> | ||
<p className="line-clamp-1 overflow-hidden">{post.title}</p> | ||
</Link> | ||
</CardTitle> | ||
<CardDescription> | ||
{post.date} | {post.author} | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<p className="line-clamp-1 overflow-hidden">{post.excerpt}</p> | ||
</CardContent> | ||
<CardFooter className="flex flex-wrap gap-2"> | ||
{post.tags.map((tag) => ( | ||
<Badge | ||
key={tag} | ||
variant="secondary" | ||
className="text-xs px-2 py-1 h-6 cursor-pointer" | ||
onClick={() => onTagClick(tag)} | ||
> | ||
{tag} | ||
</Badge> | ||
))} | ||
</CardFooter> | ||
</Card> | ||
</motion.div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Label, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@/components/ui"; | ||
|
||
type SortOption = "date" | "title"; | ||
|
||
interface BlogSearchProps { | ||
searchTerm: string; | ||
onSearchChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
sortOption: SortOption; | ||
onSortChange: (value: SortOption) => void; | ||
} | ||
|
||
export function BlogSearch({ searchTerm, onSearchChange, sortOption, onSortChange }: BlogSearchProps) { | ||
return ( | ||
<div className="mb-6 flex items-end space-x-4"> | ||
<div className="flex-grow"> | ||
<Label htmlFor="search" className="mb-2 block"> | ||
搜索文章 | ||
</Label> | ||
<Input | ||
id="search" | ||
type="text" | ||
placeholder="输入关键词..." | ||
value={searchTerm} | ||
onChange={onSearchChange} | ||
/> | ||
</div> | ||
<div className="w-40"> | ||
<Label htmlFor="sort" className="mb-2 block"> | ||
排序方式 | ||
</Label> | ||
<Select onValueChange={onSortChange} defaultValue={sortOption}> | ||
<SelectTrigger id="sort" className="w-full"> | ||
<SelectValue placeholder="选择排序方式" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectItem value="date">按日期排序</SelectItem> | ||
<SelectItem value="title">按标题排序</SelectItem> | ||
</SelectContent> | ||
</Select> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.