test: post title view transition

- Remove transition names from date and reading time spans
- Wrap post title in a span for view transition
- Add font-bold utility to h1 in Heti CSS
- Simplify reading time display logic
This commit is contained in:
radishzzz 2025-02-15 22:09:14 +00:00
parent 67bc3a63c9
commit 7861156651
3 changed files with 13 additions and 12 deletions

View file

@ -46,14 +46,12 @@ const postsByYear = await getPostsByYear()
</a> </a>
{/* Post Date */} {/* Post Date */}
<div class="mb-9 block text-5.6 leading-11 font-time lg:ml-4 lg:inline"> <div class="mb-9 block text-5.6 leading-11 font-time lg:ml-4 lg:inline">
<span transition:name={`date-${post.data.slug || post.slug}`}> <span>
{post.data.published.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')} {post.data.published.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')}
</span> </span>
{post.remarkPluginFrontmatter?.minutes && ( <span class="ml-2" transition:name={`time-${post.data.slug || post.slug}`}>
<span class="ml-2" transition:name={`time-${post.data.slug || post.slug}`}> {post.remarkPluginFrontmatter?.minutes} min
{post.remarkPluginFrontmatter.minutes} min </span>
</span>
)}
</div> </div>
</li> </li>
))} ))}

View file

@ -25,16 +25,18 @@ const { Content, remarkPluginFrontmatter } = await post.render()
postImage={post.data.image} postImage={post.data.image}
> >
<article class="heti"> <article class="heti">
<h1 transition:name={`post-${post.data.slug || post.slug}`}>{post.data.title}</h1> <h1>
<span transition:name={`post-${post.data.slug || post.slug}`}>
{post.data.title}
</span>
</h1>
<time> <time>
<span transition:name={`date-${post.data.slug || post.slug}`}> <span>
{post.data.published.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' }).replace('/', '-')} {post.data.published.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' }).replace('/', '-')}
</span> </span>
{remarkPluginFrontmatter.minutes && ( <span>
<span transition:name={`time-${post.data.slug || post.slug}`}> {remarkPluginFrontmatter.minutes} min
· {remarkPluginFrontmatter.minutes} min
</span> </span>
)}
</time> </time>
<Content /> <Content />
</article> </article>

View file

@ -116,6 +116,7 @@
font-weight:600 font-weight:600
} }
.heti h1 { .heti h1 {
--at-apply: 'font-bold';
margin-block-end:24px; margin-block-end:24px;
font-size:32px; font-size:32px;
line-height:48px line-height:48px