+ + {post.title} + +
+ ++ {post.description} +
+ + {/* Tags */} +diff --git a/src/components/BlogList.tsx b/src/components/BlogList.tsx new file mode 100644 index 0000000..61b3fe9 --- /dev/null +++ b/src/components/BlogList.tsx @@ -0,0 +1,124 @@ +import React from 'react'; +import { useTranslations, type Lang } from '../i18n/utils'; + +/** + * Blog post interface definition + */ +interface BlogPost { + title: string; + description: string; + image: string; + slug: string; + tags: string[]; + date: string; + readTime: string; +} + +/** + * Props interface for BlogList component + */ +interface BlogListProps { + posts: BlogPost[]; + lang: Lang; + baseUrl?: string; // Base URL for blog posts, defaults to '/blog/posts/' +} + +/** + * Reusable blog list component that displays blog posts in a grid layout + * @param posts - Array of blog posts to display + * @param lang - Current language for internationalization + * @param baseUrl - Base URL for blog post links + */ +export default function BlogList({ posts, lang, baseUrl = '/blog/posts/' }: BlogListProps) { + const t = useTranslations(lang); + + // Adjust base URL for Chinese language + const postBaseUrl = lang === 'zh' ? '/zh/blog/posts/' : baseUrl; + + // Get localized "Read More" text + const readMoreText = lang === 'zh' ? '阅读更多' : 'Read More'; + + return ( +
+ {post.description} +
+ + {/* Tags */} ++ Dive into my thoughts on coding, tech trends, and developer life. Explore my latest posts below. +
++ 深入我对编程、技术趋势和开发者生活的思考。探索我的最新文章。 +
+