add PostGrid component

This commit is contained in:
ebby 2026-06-21 19:12:31 +02:00
parent 5da0393628
commit 3acf304f86
2 changed files with 30 additions and 20 deletions

View file

@ -0,0 +1,27 @@
---
import type { Post } from "../types/global";
import PostPreviewSmall from "./PostPreviewSmall.astro";
interface Props {
posts: Array<Post>;
}
const { posts } = Astro.props;
---
<div class="post-grid">
{
posts.map((post_file: any) => (
<PostPreviewSmall url={post_file.url} post={post_file.frontmatter} />
))
}
</div>
<style>
.post-grid {
padding: 24px 24px;
display: flex;
gap: 32px;
flex-wrap: wrap;
}
</style>

View file

@ -1,14 +1,14 @@
---
import Main from "../layouts/Main.astro";
import PostPreviewSmall from "../components/PostPreviewSmall.astro";
import PostPreviewLarge from "../components/PostPreviewLarge.astro";
import PostGrid from "../components/PostGrid.astro";
const allPosts: Array<any> = Object.values(
import.meta.glob("./posts/*.md", { eager: true })
);
const posts = allPosts.slice(0, allPosts.length - 1)
const mostRecentPost = allPosts.at(allPosts.length - 1);
console.log(mostRecentPost)
---
<Main title="Startseite">
@ -16,22 +16,5 @@ console.log(mostRecentPost)
url={mostRecentPost.url}
post={mostRecentPost.frontmatter}
/>
<div class="post-grid">
{
allPosts
.slice(0, allPosts.length - 1)
.map((post_file: any) => (
<PostPreviewSmall url={post_file.url} post={post_file.frontmatter} />
))
}
</div>
<PostGrid posts={posts} />
</Main>
<style>
.post-grid {
padding: 24px 24px;
display: flex;
gap: 32px;
flex-wrap: wrap;
}
</style>