blog/src/pages/index.astro
radishzzz 0f20e43484 refactor: remove underline animation and update styling
- Remove underline-animation UnoCSS shortcut from uno.config.ts
- Update Navbar component to remove underline-animation classes
- Remove inline script for link transition animations
- Add cover images to existing posts
- Update font and date display classes in index pages
- Modify global CSS for iOS rendering optimization
2025-01-28 04:33:47 +00:00

52 lines
1.8 KiB
Text

---
import Layout from '@/layouts/Layout.astro'
import { getPinnedPosts, getPostsByYear } from '@/utils/content'
const pinnedPosts = await getPinnedPosts()
const postsByYear = await getPostsByYear()
---
<Layout>
<main>
{pinnedPosts.length > 0 && (
<section>
<ul>
{pinnedPosts.map(post => (
<li>
<a href={`/posts/${post.data.slug || post.slug}/`}>
{post.data.title}
<div class="block lg:inline lg:before:content-['_']">
{post.data.published.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' }).replace('/', '-')}
{post.remarkPluginFrontmatter?.minutes && <span> {post.remarkPluginFrontmatter.minutes} min</span>}
</div>
</a>
</li>
))}
</ul>
</section>
)}
{[...postsByYear.entries()].map(([year, posts]) => (
// Year Group
<section class="mt-8">
{/* Year */}
<time class="text-8 font-navbar">{year}</time>
{/* Posts List */}
<ul>
{posts.map(post => (
// Single Post
<li class="mt-6">
{/* Post Title */}
<a class="hover:text-secondary" href={`/posts/${post.data.slug || post.slug}`}>{post.data.title}</a>
{/* Post Date */}
<div class="block text-5.6 leading-7 font-navbar lg:inline lg:before:content-['_']" aria-hidden="true">
{post.data.published.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' }).replace('/', '-')}
{post.remarkPluginFrontmatter?.minutes && <span class="ml-2"> {post.remarkPluginFrontmatter.minutes} min</span>}
</div>
</li>
))}
</ul>
</section>
))}
</main>
</Layout>