mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
refactor: refactor article list component and routing logic, optimize multilingual article display
This commit is contained in:
parent
e5165dd740
commit
ff1673da9c
19 changed files with 609 additions and 690 deletions
|
@ -1,61 +0,0 @@
|
|||
---
|
||||
// Define props received by the component
|
||||
interface Post {
|
||||
data: {
|
||||
title: string
|
||||
abbrlink?: string
|
||||
published: Date
|
||||
}
|
||||
slug?: string
|
||||
remarkPluginFrontmatter?: {
|
||||
minutes?: number
|
||||
}
|
||||
}
|
||||
|
||||
// Receive posts parameter passed from outside
|
||||
const { posts } = Astro.props
|
||||
|
||||
// Declare the type of props
|
||||
export interface Props {
|
||||
posts: Post[]
|
||||
}
|
||||
---
|
||||
<ul>
|
||||
{posts.map(post => (
|
||||
// Single Post
|
||||
<li class="mt-4.375">
|
||||
|
||||
<a
|
||||
class="hover:c-primary"
|
||||
href={`/posts/${post.data.abbrlink || post.slug}/`}
|
||||
transition:name={`post-${post.data.abbrlink || post.slug}`}
|
||||
data-disable-transition-on-theme
|
||||
>
|
||||
{post.data.title}
|
||||
</a>
|
||||
|
||||
<div
|
||||
class="uno-mobile-time"
|
||||
transition:name={`time-${post.data.abbrlink || post.slug}`}
|
||||
data-disable-transition-on-theme
|
||||
>
|
||||
<time>
|
||||
{post.data.published.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')}
|
||||
</time>
|
||||
<span class="ml-1.25">
|
||||
{post.remarkPluginFrontmatter?.minutes} min
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="uno-desktop-time">
|
||||
<time>
|
||||
{post.data.published.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')}
|
||||
</time>
|
||||
<span class="ml-1.25">
|
||||
{post.remarkPluginFrontmatter?.minutes} min
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
Loading…
Add table
Add a link
Reference in a new issue