refactor(blog): modernize post page layout with top breadcrumbs, clean typography, and responsive toolbars
Deploy Frontend / deploy (push) Successful in 1m11s

This commit is contained in:
Parsa Aghayi committed 2026-11-02 17:12:40 +00:00
1 parent 58366cc6a6
commit 0d6aaa10c8
1 file changed
+162 -155
+162 -155
View File
@@ -177,7 +177,7 @@ export default async function SinglePost(props: PostSlugPagepropsType) {
};
return (
<div className="flex w-full max-w-[1280px] flex-wrap justify-center sm:my-10">
<div className="flex w-full max-w-[1280px] flex-col items-center px-4 sm:px-6 sm:my-10">
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
@@ -190,121 +190,113 @@ export default async function SinglePost(props: PostSlugPagepropsType) {
__html: JSON.stringify(breadcrumbJsonLd),
}}
/>
<div className="mt-5 flex w-full max-w-[90%] flex-col gap-5">
<h1 className="text-[36px] font-[700] capitalize text-blog-text-default">
{/* Breadcrumbs - placed top before title */}
<nav aria-label="breadcrumb" className="w-full max-w-4xl py-4">
<ul className="flex flex-wrap items-center gap-1.5 text-xs text-blog-text-passive">
<li>
<Link
href="/blog"
className="hover:text-blog-purple hover:underline transition-colors"
>
{dict.blog.header.Home}
</Link>
</li>
<li aria-hidden="true" className="select-none opacity-40">{"/"}</li>
<li>
<Link
href="/blog/categories"
className="hover:text-blog-purple hover:underline transition-colors"
>
{dict.blog.header.Categories}
</Link>
</li>
{categoryName && categorySlug ? (
<>
<li aria-hidden="true" className="select-none opacity-40">{"/"}</li>
<li>
<Link
href={`/blog/categories/${categorySlug}`}
className="hover:text-blog-purple hover:underline transition-colors"
>
{categoryName}
</Link>
</li>
</>
) : null}
</ul>
</nav>
{/* Article Header */}
<header className="flex w-full max-w-4xl flex-col gap-4 pb-6">
<h1 className="text-2xl sm:text-3xl md:text-4xl font-extrabold leading-tight text-blog-text-default">
{post.title}
</h1>
{post.excerpt ? (
<p className="text-[18px] font-[600] text-blog-text-default">
<p className="text-sm sm:text-base md:text-lg leading-relaxed text-blog-text-passive">
{post.excerpt}
</p>
) : null}
<div className="flex w-full flex-wrap gap-2">
<div className="flex flex-wrap items-center gap-3 pt-2 text-xs sm:text-sm text-blog-text-passive border-b border-white/5 pb-4">
{authorName ? (
<div className="flex gap-2">
<p className="text-[14px] font-[600] text-blog-text-passive md:text-[16px]">
{dict.blog.homePage.by}
</p>
<div className="flex items-center gap-1.5">
<span>{dict.blog.homePage.by}</span>
<Link
href={AUTHOR_PROFILE_URL}
target="_blank"
rel="noopener noreferrer"
className="whitespace-nowrap text-[14px] font-[400] capitalize text-blog-text-default hover:underline md:text-[16px]"
className="font-medium text-blog-text-default hover:underline"
>
{authorName}
</Link>
</div>
) : null}
{categoryName && categorySlug ? (
<div className="whit flex gap-2">
<p className="text-[16px] font-[600] text-blog-text-passive">
{dict.blog.homePage.in}
</p>
<div className="flex items-center gap-1.5">
<span>{dict.blog.homePage.in}</span>
<Link
href={`/blog/categories/${categorySlug}`}
className="text-[16px] font-[400] text-blog-text-default hover:underline"
className="font-medium text-blog-purple hover:underline"
>
{categoryName}
</Link>
</div>
) : null}
{publishedDate ? (
<p className="whitespace-nowrap text-[16px] font-[400] text-blog-text-passive">
{publishedDate}
</p>
<span>{publishedDate}</span>
) : null}
{readingTime > 0 ? (
<p className="whitespace-nowrap rounded-full border border-blog-text-passive px-3 py-1 text-[13px] font-[600] text-blog-text-passive">
<span className="rounded-full bg-white/5 px-2.5 py-0.5 text-xs font-medium text-blog-text-passive border border-white/10">
{readingTime} {dict.blog.postSinglePage.readTime}
</p>
</span>
) : null}
</div>
</div>
<div className="my-10 flex w-full max-w-[90%] flex-wrap justify-center gap-5">
<ul className="my-10 flex w-full flex-wrap gap-2">
<li className="flex items-center gap-2">
<Link
href="/blog"
className="text-[12px] font-[400] capitalize text-blog-text-passive hover:underline"
>
{dict.blog.header.Home}
</Link>
<span className="mt-[-2px] -rotate-45 scale-[3] select-none text-[12px] font-[400] text-blog-text-passive">
-
</span>
</li>
<li className="flex items-center gap-2">
<Link
href="/blog/categories"
className="text-[12px] font-[400] capitalize text-blog-text-passive hover:underline"
>
{dict.blog.header.Categories}
</Link>
<span className="mt-[-2px] -rotate-45 scale-[3] select-none text-[12px] font-[400] text-blog-text-passive">
-
</span>
</li>
{categoryName && categorySlug ? (
<li className="flex items-center gap-2">
<Link
href={`/blog/categories/${categorySlug}`}
className="text-[12px] font-[400] capitalize text-blog-text-passive hover:underline"
>
{categoryName}
</Link>
<span className="mt-[-2px] -rotate-45 scale-[3] select-none text-[12px] font-[400] text-blog-text-passive">
-
</span>
</li>
) : null}
<li className="flex items-center gap-2">
<p className="text-[12px] font-[600] capitalize text-blog-text-default">
{post.title}
</p>
</li>
</ul>
</header>
<div className="relative flex w-full items-start justify-center gap-3 sm:gap-4 md:gap-5">
<div className="sticky top-[150px] flex flex-col items-start gap-8">
{headings.length > 0 ? (
<nav
aria-label={dict.blog.postSinglePage.onThisPage}
className="hidden max-h-[60vh] w-[210px] flex-col gap-2 overflow-y-auto border-s-2 border-blog-text-passive ps-3 motion-safe:scroll-smooth lg:flex"
>
<p className="text-[14px] font-[700] capitalize text-blog-text-default">
{dict.blog.postSinglePage.onThisPage}
</p>
{headings.map((heading) => (
<a
key={heading.id}
href={`#${heading.id}`}
className="text-[13px] font-[400] leading-snug text-blog-text-passive hover:text-blog-purple hover:underline"
>
{heading.text}
</a>
))}
</nav>
) : null}
{/* Main Content Area */}
<div className="flex w-full max-w-6xl justify-center gap-6 lg:gap-10">
{/* Left Side: On this page & Share (desktop only) */}
<aside className="hidden lg:flex sticky top-28 h-fit w-52 shrink-0 flex-col gap-8">
{headings.length > 0 ? (
<nav
aria-label={dict.blog.postSinglePage.onThisPage}
className="flex max-h-[60vh] flex-col gap-2 overflow-y-auto border-s-2 border-blog-text-passive/30 ps-3 motion-safe:scroll-smooth text-xs"
>
<p className="font-bold uppercase tracking-wider text-blog-text-default">
{dict.blog.postSinglePage.onThisPage}
</p>
{headings.map((heading) => (
<a
key={heading.id}
href={`#${heading.id}`}
className="font-normal leading-snug text-blog-text-passive hover:text-blog-purple hover:underline"
>
{heading.text}
</a>
))}
</nav>
) : null}
<div className="flex flex-col gap-2">
<ShareButtons
vertical
title={post.title}
@@ -312,91 +304,107 @@ export default async function SinglePost(props: PostSlugPagepropsType) {
dict={dict.blog.postSinglePage}
/>
</div>
</aside>
<div className="relative flex w-[95%] flex-wrap gap-5">
{coverImage ? (
{/* Center: Article Body */}
<article className="flex w-full max-w-3xl flex-col gap-6">
{coverImage ? (
<div className="relative overflow-hidden rounded-2xl border border-white/10 shadow-lg">
<Image
className="h-auto w-full"
className="h-auto w-full object-cover"
src={coverImage}
width={1200}
height={800}
height={630}
priority
alt={`${post.title} post featured image`}
/>
) : null}
<div className="flex w-full flex-col gap-5">
{renderBody(post.body, post.excerpt)}
</div>
) : null}
{postTags.length > 0 ? (
<ul className="my-5 flex w-full flex-wrap gap-2">
{postTags.map((tag) => (
<li key={tag.id}>
<Link
href={`/blog/tags/${tag.slug}`}
className="text-[14px] font-[400] text-blog-blue hover:underline"
>
#{tag.name}
</Link>
</li>
))}
</ul>
) : null}
{authorName ? (
<div className="my-10 flex w-full justify-center">
<div className="flex flex-col items-center">
<Image
src={"/images/blog/users/1.png"}
alt={"post author image"}
width={80}
height={80}
className="mb-2 rounded-full"
/>
<Link
href="/"
className="text-center text-[18px] font-[400] capitalize text-blog-text-default hover:underline"
>
{authorName}
</Link>
<p className="text-[16px] font-[400] capitalize text-blog-text-default">
{dict.blog.postSinglePage.followMe}
<Link
href={AUTHOR_PROFILE_URL}
target="_blank"
rel="noopener noreferrer"
className="ms-1 text-[16px] font-[400] lowercase text-blog-blue"
>
@parsaaghayi
</Link>
.
</p>
</div>
</div>
) : null}
</div>
<div className="sticky top-[150px] flex flex-col items-end gap-5">
<PostStats
slug={post.slug ?? params.postSlug}
initialViews={post.views}
initialLikes={post.likes}
likeAriaLabel={dict.blog.postSinglePage.likeButton}
{/* Mobile inline stats & share toolbar */}
<div className="flex lg:hidden items-center justify-between rounded-xl bg-white/5 border border-white/10 p-3 my-2">
<div className="flex items-center gap-4">
<PostStats
slug={post.slug ?? params.postSlug}
initialViews={post.views}
initialLikes={post.likes}
likeAriaLabel={dict.blog.postSinglePage.likeButton}
/>
</div>
<ShareButtons
title={post.title}
url={pageUrl}
dict={dict.blog.postSinglePage}
/>
</div>
</div>
<div className="flex w-full flex-col gap-6 text-sm sm:text-base leading-relaxed">
{renderBody(post.body, post.excerpt)}
</div>
{postTags.length > 0 ? (
<ul className="my-6 flex w-full flex-wrap gap-2 pt-4 border-t border-white/10">
{postTags.map((tag) => (
<li key={tag.id}>
<Link
href={`/blog/tags/${tag.slug}`}
className="rounded-lg bg-white/5 px-2.5 py-1 text-xs font-medium text-blog-blue hover:bg-white/10 hover:underline transition-colors"
>
#{tag.name}
</Link>
</li>
))}
</ul>
) : null}
{authorName ? (
<div className="my-8 flex w-full justify-center rounded-2xl bg-white/5 border border-white/10 p-6">
<div className="flex flex-col items-center text-center">
<Image
src={"/images/blog/users/1.png"}
alt={"post author image"}
width={72}
height={72}
className="mb-3 rounded-full border-2 border-primary/20"
/>
<Link
href="/"
className="text-base font-bold text-blog-text-default hover:underline"
>
{authorName}
</Link>
<p className="mt-1 text-xs sm:text-sm text-blog-text-passive">
{dict.blog.postSinglePage.followMe}
<Link
href={AUTHOR_PROFILE_URL}
target="_blank"
rel="noopener noreferrer"
className="ms-1 font-medium text-blog-blue"
>
@parsaaghayi
</Link>
</p>
</div>
</div>
) : null}
</article>
{/* Right Side: Post Stats (desktop only) */}
<aside className="hidden lg:flex sticky top-28 h-fit shrink-0 flex-col items-center gap-6">
<PostStats
slug={post.slug ?? params.postSlug}
initialViews={post.views}
initialLikes={post.likes}
likeAriaLabel={dict.blog.postSinglePage.likeButton}
/>
</aside>
</div>
<div className="my-10 mt-20 flex w-full flex-wrap gap-10">
<div className="flex w-full items-center justify-between">
<p className="text-[22px] font-[600] capitalize text-blog-text-default">
{dict.blog.postSinglePage.YouMightLike}
</p>
{/* <Link
href={"#"}
className="text-[22px] font-[600] capitalize text-blog-text-passive hover:underline"
>
more
</Link> */}
</div>
<div className="flex w-full flex-wrap justify-between gap-5">
{relatedPosts.slice(0, 2).map((relatedPost: PostType) => (
@@ -498,7 +506,6 @@ export default async function SinglePost(props: PostSlugPagepropsType) {
error: dict.blog.postSinglePage.commentError,
}}
/>
</div>
</div>
);
}