Refine single post header layout and styling

This commit is contained in:
2025-11-17 18:12:09 +08:00
parent 3feeaf0fbc
commit 309e7fc2bc

View File

@@ -40,8 +40,32 @@ export default function BlogPostPage({ params }: Props) {
<aside className="hidden w-56 shrink-0 lg:block"> <aside className="hidden w-56 shrink-0 lg:block">
<PostToc /> <PostToc />
</aside> </aside>
<article className="prose prose-slate max-w-none flex-1 dark:prose-dark"> <div className="flex-1">
<h1>{post.title}</h1> <header className="mb-6 space-y-2">
{post.published_at && (
<p className="text-xs text-slate-500 dark:text-slate-400">
{new Date(post.published_at).toLocaleDateString(
siteConfig.defaultLocale
)}
</p>
)}
<h1 className="text-2xl font-bold leading-tight text-slate-900 sm:text-3xl dark:text-slate-50">
{post.title}
</h1>
{post.tags && (
<div className="flex flex-wrap gap-2 pt-1">
{post.tags.map((t) => (
<span
key={t}
className="rounded-full bg-slate-100 px-2 py-0.5 text-xs text-slate-700 dark:bg-slate-800 dark:text-slate-200"
>
#{t}
</span>
))}
</div>
)}
</header>
<article className="prose prose-slate max-w-none dark:prose-dark">
{post.feature_image && ( {post.feature_image && (
// feature_image is stored as "../assets/xyz", serve from "/assets/xyz" // feature_image is stored as "../assets/xyz", serve from "/assets/xyz"
// eslint-disable-next-line @next/next/no-img-element // eslint-disable-next-line @next/next/no-img-element
@@ -51,28 +75,10 @@ export default function BlogPostPage({ params }: Props) {
className="my-4 rounded" className="my-4 rounded"
/> />
)} )}
{post.published_at && (
<p className="text-xs text-slate-500 dark:text-slate-400">
{new Date(post.published_at).toLocaleDateString(
siteConfig.defaultLocale
)}
</p>
)}
{post.tags && (
<p className="mt-1 text-xs text-slate-600 dark:text-slate-200">
{post.tags.map((t) => (
<span
key={t}
className="mr-1 rounded bg-slate-100 px-1 dark:bg-slate-800"
>
#{t}
</span>
))}
</p>
)}
<div dangerouslySetInnerHTML={{ __html: post.body.html }} /> <div dangerouslySetInnerHTML={{ __html: post.body.html }} />
</article> </article>
</div> </div>
</div>
</> </>
); );
} }