Skip to content

Commit

Permalink
init post
Browse files Browse the repository at this point in the history
  • Loading branch information
viperML committed Jul 5, 2024
1 parent 010594a commit 47f4ce8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
29 changes: 29 additions & 0 deletions src/components/Post.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
import type { CollectionEntry } from "astro:content";
interface Props {
post: CollectionEntry<"blog">;
}
const { post } = Astro.props;
---

<li id="post-container">
<h3>
<a href={`/blog/${post.slug}`}>
{post.data.title}
</a>
</h3>

<h4>
{post.data.summary}
</h4>
</li>

<style>
#post-container {
background-color: white;
display: grid;
grid-template-rows: auto auto;

padding: 1rem;
}
</style>
20 changes: 13 additions & 7 deletions src/components/PostList.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import { getCollection } from "astro:content";
import Post from "./Post.astro";
// const blogEntries = (await getCollection("blog")).filter((data) => {
// const draft = (() => {
Expand Down Expand Up @@ -39,14 +40,19 @@ const blogEntries = (await getCollection("blog"))
});
---

<h1>Post List</h1>
<h1>All posts</h1>

<ul>
<ul class="flex flex-col gap-3">
{
blogEntries.map((item) => (
<li>
<a href={`/blog/${item.slug}`}>{item.slug}</a>
</li>
))
blogEntries.map((item) => {
// console.log(item);
return <Post post={item} />;
})
}
</ul>

<style>
h1 {
padding-bottom: 2rem;
}
</style>
9 changes: 8 additions & 1 deletion src/layouts/Base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,21 @@ import NavBar from "../components/NavBar.astro";
padding-bottom: 0.5rem;
}

h3 {
font-weight: 800;
font-size: 1.2em;
}

h1:hover,
h2:hover {
h2:hover,
h3:hover {
text-decoration: underline;
}

a:hover {
text-decoration: underline;
}

</style>

<script is:inline>
Expand Down

0 comments on commit 47f4ce8

Please sign in to comment.