From 99490cfd0b8461de337d88b99bcb1a826a42a08e Mon Sep 17 00:00:00 2001 From: javayhu Date: Sat, 8 Mar 2025 18:39:57 +0800 Subject: [PATCH] feat: update blog page localization and styling - Change "publisher" to "author" in English and Chinese translation files - Add Lucide icons for date and reading time in blog post page - Implement link underline animation in global CSS - Enhance blog post page layout with icon-based metadata display - Improve visual consistency and internationalization for blog components --- messages/en.json | 2 +- messages/zh.json | 2 +- .../(marketing)/blog/[...slug]/page.tsx | 33 +++++++++++-------- src/styles/globals.css | 7 ++++ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/messages/en.json b/messages/en.json index c485c97..6f7e389 100644 --- a/messages/en.json +++ b/messages/en.json @@ -66,7 +66,7 @@ "BlogPage": { "title": "Blog", "subtitle": "Latest news and updates from our team", - "publisher": "Publisher", + "author": "Author", "categories": "Categories", "tableOfContents": "Table of Contents", "all": "All", diff --git a/messages/zh.json b/messages/zh.json index 6de5f6b..6b459fa 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -66,7 +66,7 @@ "BlogPage": { "title": "博客", "subtitle": "来自我们的团队最新新闻和更新", - "publisher": "发布者", + "author": "作者", "categories": "分类", "tableOfContents": "目录", "all": "全部", diff --git a/src/app/[locale]/(marketing)/blog/[...slug]/page.tsx b/src/app/[locale]/(marketing)/blog/[...slug]/page.tsx index 782558c..e1452e3 100644 --- a/src/app/[locale]/(marketing)/blog/[...slug]/page.tsx +++ b/src/app/[locale]/(marketing)/blog/[...slug]/page.tsx @@ -7,10 +7,11 @@ import { getBaseUrl } from '@/lib/urls/get-base-url'; import { estimateReadingTime, getLocaleDate } from '@/lib/utils'; import type { NextPageProps } from '@/types/next-page-props'; import { allPosts } from 'content-collections'; +import { CalendarIcon, ClockIcon } from 'lucide-react'; import type { Metadata } from 'next'; +import { getTranslations } from 'next-intl/server'; import Image from 'next/image'; import { notFound } from 'next/navigation'; -import { getTranslations } from 'next-intl/server'; import '@/styles/mdx.css'; @@ -35,28 +36,28 @@ async function getBlogPostFromParams(props: NextPageProps) { if (!params) { return null; } - + const locale = params.locale as string; const slug = (Array.isArray(params.slug) ? params.slug?.join('/') : params.slug) || ''; - + // Find post with matching slug and locale const post = allPosts.find( - (post) => - (post.slugAsParams === slug || (!slug && post.slugAsParams === 'index')) && + (post) => + (post.slugAsParams === slug || (!slug && post.slugAsParams === 'index')) && post.locale === locale ); - + if (!post) { // If no post found with the current locale, try to find one with the default locale const defaultPost = allPosts.find( - (post) => + (post) => (post.slugAsParams === slug || (!slug && post.slugAsParams === 'index')) ); - + return defaultPost; } - + return post; } @@ -115,8 +116,14 @@ export default async function BlogPostPage(props: NextPageProps) { {/* blog post date */}
-

{date}

-

{estimateReadingTime(post.body.raw)}

+
+ +

{date}

+
+
+ +

{estimateReadingTime(post.body.raw)}

+
{/* blog post title */} @@ -141,7 +148,7 @@ export default async function BlogPostPage(props: NextPageProps) {
{/* author info */}
-

{t("publisher")}

+

{t("author")}

{post.author?.avatar && ( @@ -166,7 +173,7 @@ export default async function BlogPostPage(props: NextPageProps) {
  • {category.name} diff --git a/src/styles/globals.css b/src/styles/globals.css index f568551..5d6bbb0 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -62,3 +62,10 @@ @apply bg-background text-foreground; } } + +@layer utilities { + .link-underline-animation { + @apply relative underline underline-offset-4 decoration-transparent decoration-2 + hover:decoration-primary hover:text-primary transition-all duration-300 ease-in-out; + } +} \ No newline at end of file