diff options
Diffstat (limited to 'src/pages/blog')
-rw-r--r-- | src/pages/blog/[...slug].astro | 10 | ||||
-rw-r--r-- | src/pages/blog/index.astro | 19 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 41b0f5c..c4e542c 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -33,10 +33,12 @@ const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY" <Layout description={post.data.description} title={post.data.title}> <article> <section> + <h1>{post.data.title}</h1> + </section> + + <section> <p> <small> - <a href="/">< Home</a> - <span> • </span> Posted <time datetime={post.data.pubDate.toISOString()}>{formattedDate}</time> by {post.data.author} @@ -47,10 +49,6 @@ const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY" </section> <section> - <h1>{post.data.title}</h1> - </section> - - <section> <Content /> </section> diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro new file mode 100644 index 0000000..48d33e8 --- /dev/null +++ b/src/pages/blog/index.astro @@ -0,0 +1,19 @@ +--- +import { getCollection } from "astro:content"; +import Layout from "../../layouts/BaseLayout.astro"; +import PostElement from "../../components/PostElement.astro"; + +const posts = await getCollection("blog", ({ data }) => { + return data.draft !== true; +}); + +posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime()); +--- + +<Layout> + <section style={{ "margin-top": "3rem" }}> + <ul> + {posts.map((post) => <PostElement post={post} />)} + </ul> + </section> +</Layout> |