add PostGrid component
This commit is contained in:
parent
5da0393628
commit
3acf304f86
2 changed files with 30 additions and 20 deletions
27
src/components/PostGrid.astro
Normal file
27
src/components/PostGrid.astro
Normal 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>
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
---
|
---
|
||||||
import Main from "../layouts/Main.astro";
|
import Main from "../layouts/Main.astro";
|
||||||
import PostPreviewSmall from "../components/PostPreviewSmall.astro";
|
|
||||||
import PostPreviewLarge from "../components/PostPreviewLarge.astro";
|
import PostPreviewLarge from "../components/PostPreviewLarge.astro";
|
||||||
|
import PostGrid from "../components/PostGrid.astro";
|
||||||
|
|
||||||
const allPosts: Array<any> = Object.values(
|
const allPosts: Array<any> = Object.values(
|
||||||
import.meta.glob("./posts/*.md", { eager: true })
|
import.meta.glob("./posts/*.md", { eager: true })
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const posts = allPosts.slice(0, allPosts.length - 1)
|
||||||
const mostRecentPost = allPosts.at(allPosts.length - 1);
|
const mostRecentPost = allPosts.at(allPosts.length - 1);
|
||||||
console.log(mostRecentPost)
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<Main title="Startseite">
|
<Main title="Startseite">
|
||||||
|
|
@ -16,22 +16,5 @@ console.log(mostRecentPost)
|
||||||
url={mostRecentPost.url}
|
url={mostRecentPost.url}
|
||||||
post={mostRecentPost.frontmatter}
|
post={mostRecentPost.frontmatter}
|
||||||
/>
|
/>
|
||||||
<div class="post-grid">
|
<PostGrid posts={posts} />
|
||||||
{
|
|
||||||
allPosts
|
|
||||||
.slice(0, allPosts.length - 1)
|
|
||||||
.map((post_file: any) => (
|
|
||||||
<PostPreviewSmall url={post_file.url} post={post_file.frontmatter} />
|
|
||||||
))
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</Main>
|
</Main>
|
||||||
|
|
||||||
<style>
|
|
||||||
.post-grid {
|
|
||||||
padding: 24px 24px;
|
|
||||||
display: flex;
|
|
||||||
gap: 32px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue