blog-section.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. "use client"
  2. import { Button } from "@/components/ui/button"
  3. import { Card, CardContent } from "@/components/ui/card"
  4. import { Badge } from "@/components/ui/badge"
  5. import { CalendarIcon, ArrowRightIcon } from "lucide-react"
  6. import Image from "next/image"
  7. import Link from "next/link"
  8. import { useTranslations } from "next-intl"
  9. interface BlogSectionProps {
  10. locale: string
  11. }
  12. export default function BlogSection({ locale }: BlogSectionProps) {
  13. const t = useTranslations("blog")
  14. // 博客文章配置,按时间顺序排列(最新的在前)
  15. const blogPostsConfig = [
  16. {
  17. key: "contact",
  18. link: `/${locale}/blog/contact-us`,
  19. sortDate: "2025-06-01",
  20. image: "/images/Get in Touch with Aiartools Team.png"
  21. },
  22. {
  23. key: "editingGuide",
  24. link: `/${locale}/blog/how-to-edit-images`,
  25. sortDate: "2025-06-01",
  26. image: "/images/How to Edit Images with Aiartools.png"
  27. },
  28. {
  29. key: "introduction",
  30. link: `/${locale}/blog/introducing-aiartools`,
  31. sortDate: "2025-05-31",
  32. image: "/images/Transform Your Images with the Power of AI.png"
  33. },
  34. ]
  35. // 按时间排序(最新的在前)
  36. const sortedPosts = blogPostsConfig.sort((a, b) =>
  37. new Date(b.sortDate).getTime() - new Date(a.sortDate).getTime()
  38. )
  39. return (
  40. <section id="blog" className="py-20">
  41. <div className="container mx-auto px-4 sm:px-6 lg:px-8">
  42. <div className="text-center mb-16">
  43. <h2 className="text-3xl md:text-4xl font-bold mb-4">{t("title")}</h2>
  44. <p className="text-xl text-muted-foreground max-w-3xl mx-auto">{t("subtitle")}</p>
  45. </div>
  46. <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mb-12">
  47. {sortedPosts.map((postConfig, index) => (
  48. <Card
  49. key={index}
  50. className="group hover:shadow-lg transition-all duration-300 overflow-hidden bg-background/60 backdrop-blur-sm border-0"
  51. >
  52. <Link href={postConfig.link}>
  53. <div className="relative overflow-hidden">
  54. <Image
  55. src={postConfig.image}
  56. alt={t(`posts.${postConfig.key}.title`)}
  57. width={300}
  58. height={200}
  59. className="w-full h-48 object-cover group-hover:scale-105 transition-transform duration-300"
  60. />
  61. <div className="absolute top-4 left-4">
  62. <Badge variant="secondary" className="bg-background/80 backdrop-blur-sm">
  63. {t(`posts.${postConfig.key}.category`)}
  64. </Badge>
  65. </div>
  66. </div>
  67. </Link>
  68. <CardContent className="p-6">
  69. <div className="flex items-center text-sm text-muted-foreground mb-3">
  70. <CalendarIcon className="w-4 h-4 mr-2" />
  71. {t(`posts.${postConfig.key}.date`)}
  72. <span className="mx-2">•</span>
  73. {t(`posts.${postConfig.key}.readTime`)}
  74. </div>
  75. <Link href={postConfig.link}>
  76. <h3 className="text-xl font-semibold mb-3 group-hover:text-primary transition-colors cursor-pointer">
  77. {t(`posts.${postConfig.key}.title`)}
  78. </h3>
  79. </Link>
  80. <p className="text-muted-foreground leading-relaxed mb-4">
  81. {t(`posts.${postConfig.key}.excerpt`)}
  82. </p>
  83. <Link href={postConfig.link}>
  84. <Button variant="ghost" className="p-0 h-auto font-semibold text-primary hover:text-primary/80">
  85. {t("readMore")}
  86. <ArrowRightIcon className="w-4 h-4 ml-2" />
  87. </Button>
  88. </Link>
  89. </CardContent>
  90. </Card>
  91. ))}
  92. </div>
  93. <div className="text-center">
  94. <Link href={`/${locale}/blog`}>
  95. <Button size="lg" variant="outline">
  96. {t("viewAllPosts")}
  97. <ArrowRightIcon className="w-5 h-5 ml-2" />
  98. </Button>
  99. </Link>
  100. </div>
  101. </div>
  102. </section>
  103. )
  104. }