mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-blog.git
synced 2026-04-02 01:54:50 +00:00
27 lines
613 B
Text
27 lines
613 B
Text
---
|
|
import { getCollection } from "astro:content";
|
|
import PostItem from "./PostItem.astro";
|
|
import { getLangFromUrl, getTranslations, type Lang } from "@/i18n";
|
|
|
|
const lang = getLangFromUrl(Astro.url);
|
|
const t = getTranslations(lang);
|
|
const allPosts = await getCollection("blog");
|
|
---
|
|
|
|
<ul>
|
|
{
|
|
allPosts.map((post: any) => {
|
|
const formattedDate = new Date(post.data.pubDate)
|
|
.toISOString()
|
|
.split("T")[0];
|
|
|
|
return (
|
|
<PostItem
|
|
url={`/${lang}/posts/${post.id}/`}
|
|
title={post.data.title}
|
|
date={formattedDate}
|
|
/>
|
|
);
|
|
})
|
|
}
|
|
</ul>
|