fix(blog url bug): fix blog url bug

Fixed the bug of redundant language suffix in blog URLs, added lang to the blog homepage link to prevent language switching issues.
This commit is contained in:
david_bai
2025-08-02 23:27:02 +08:00
parent 3dfee10cee
commit 245c4efcd0
6 changed files with 51 additions and 46 deletions
+4 -3
View File
@@ -4,9 +4,10 @@ import { type BlogPost } from "@/lib/blog";
interface ArticleListItemProps {
post: BlogPost;
lang: string;
}
export function ArticleListItem({ post }: ArticleListItemProps) {
export function ArticleListItem({ post, lang }: ArticleListItemProps) {
return (
<article className="bg-white rounded-xl shadow-lg hover:shadow-xl transition-shadow overflow-hidden">
<div className="relative h-80 w-full">
@@ -37,7 +38,7 @@ export function ArticleListItem({ post }: ArticleListItemProps) {
))}
</div>
</div>
<Link href={`/blog/${post.slug}`}>
<Link href={`/${lang}/blog/${post.slug}`}>
<h2 className="text-3xl font-bold mb-4 hover:text-blue-600 transition-colors leading-tight">
{post.frontmatter.title}
</h2>
@@ -49,7 +50,7 @@ export function ArticleListItem({ post }: ArticleListItemProps) {
<div className="flex items-center justify-between pt-4 border-t border-gray-100">
<Link
href={`/blog/${post.slug}`}
href={`/${lang}/blog/${post.slug}`}
className="text-blue-600 hover:text-blue-800 font-medium inline-flex items-center text-lg"
>
Read more