mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
refactor: refactoring project structure and components, optimizing internationalization and page presentation
This commit is contained in:
parent
6674cb7072
commit
d6cff842e1
37 changed files with 156 additions and 146 deletions
61
src/components/PostTitleList.astro
Normal file
61
src/components/PostTitleList.astro
Normal file
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
// Define props received by the component
|
||||
interface Post {
|
||||
data: {
|
||||
title: string;
|
||||
slug?: 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.slug || post.slug}`}
|
||||
transition:name={`post-${post.data.slug || post.slug}`}
|
||||
data-disable-transition-on-theme
|
||||
>
|
||||
{post.data.title}
|
||||
</a>
|
||||
|
||||
<div
|
||||
class="uno-mobile-time"
|
||||
transition:name={`time-${post.data.slug || 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