fuwari/src/components/widget/RecentPost.astro
saicaca f4dc88e982 feat: allow collapsing widget content, add categories widget
(cherry picked from commit 9a4ca8f6163d5e1375aa7c612e1338cce5a8c0b5)
2023-10-18 02:15:28 +08:00

20 lines
No EOL
576 B
Text

---
import WidgetLayout from "./WidgetLayout.astro";
import ButtonLink from "../control/ButtonLink.astro";
import {getSortedPosts} from "../../utils/content-utils";
import {i18n} from "../../i18n/translation";
import I18nKey from "../../i18n/i18nKey";
import {getPostUrlBySlug} from "../../utils/url-utils";
let posts = await getSortedPosts()
const LIMIT = 3;
posts = posts.slice(0, LIMIT)
---
<WidgetLayout name={i18n(I18nKey.recentPosts)}>
{posts.map(post =>
<ButtonLink url={getPostUrlBySlug(post.slug)}>{post.data.title}</ButtonLink>
)}
</WidgetLayout>