improve page transitions for blog entries

This commit is contained in:
2025-11-09 14:08:28 +01:00
parent e486052413
commit 9c5a269214
3 changed files with 3 additions and 5 deletions
+1 -2
View File
@@ -31,7 +31,7 @@ const permalink = `${Astro?.site?.href}blog/${slug}`;
<BaseLayout title={title} description={description} permalink={permalink} current="blog"> <BaseLayout title={title} description={description} permalink={permalink} current="blog">
<header> <header>
<p>{publishDate} ~ {readTime}</p> <p>{publishDate} ~ {readTime}</p>
<h1>{title}</h1> <h1 style={`view-transition-name: blog-post-${slug}`}>{title}</h1>
<div class="tags" style="justify-content: center"> <div class="tags" style="justify-content: center">
{tags.map(item => ( {tags.map(item => (
<span class="tag">{item}</span> <span class="tag">{item}</span>
@@ -55,7 +55,6 @@ const permalink = `${Astro?.site?.href}blog/${slug}`;
margin-bottom: 0.7em; margin-bottom: 0.7em;
display: flex; display: flex;
justify-content: center; justify-content: center;
view-transition-name: blog-title;
width: fit-content; width: fit-content;
margin-inline: auto; margin-inline: auto;
} }
+1 -1
View File
@@ -21,7 +21,7 @@ const allPosts= posts.sort((a, b) => new Date(b.data.publishDate).valueOf() - ne
{ index !== 0 && <hr /> } { index !== 0 && <hr /> }
<div class="post-item"> <div class="post-item">
<h2> <h2>
<a data-astro-prefetch href={href}>{post.data.title}</a> <a data-astro-prefetch href={href} style={`view-transition-name: blog-post-${post.slug}`}>{post.data.title}</a>
</h2> </h2>
<div class="tags"> <div class="tags">
{post.data.tags.map(item => ( {post.data.tags.map(item => (
+1 -2
View File
@@ -49,7 +49,7 @@ const latestBlogPost = await getCollection("posts")
) : null ) : null
} }
<div class="latest-article"> <div class="latest-article">
<span class="title">{latestBlogPost?.data.title}</span> <span class="title" style={`view-transition-name: blog-post-${latestBlogPost?.slug}`}>{latestBlogPost?.data.title}</span>
<span class="excerpt">{latestBlogPost?.data.description}</span> <span class="excerpt">{latestBlogPost?.data.description}</span>
</div> </div>
<div class="actions"> <div class="actions">
@@ -178,7 +178,6 @@ const latestBlogPost = await getCollection("posts")
.title { .title {
font-weight: 600; font-weight: 600;
font-size: 1.1rem; font-size: 1.1rem;
view-transition-name: blog-title;
} }
.excerpt { .excerpt {