aboutsummaryrefslogtreecommitdiff
path: root/src/pages/blog/index.astro
blob: a6b685577a50089d841bc9b3bf6d3711b99dee83 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
import Page from "../../layouts/Page.astro";
import { getCollection } from "astro:content";
import {formatDate} from "../../util";
import "../../styles/cards.css";

const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
---
<Page title="Blog" description="Where I post can be anything!">
   <main>
      {allBlogPosts.map((post) => (
         <article>
            <h1><a href={`/blog/${post.slug}`}>{post.data.title}</a></h1>
            <small>{formatDate(post.data.pubDate)}</small>
            <p>{post.data.description}</p>
            <div class="tags">
               {post.data.tags.map((tag) => (
                  <a href={`/blog/tags/${tag}`}>{tag}</a>
               ))}
            </div>
         </article>
       ))
      }

   </main>
</Page>
<style>
   .tags {
      display: flex;
      flex-direction: row;
      gap: 1em;
   }
</style>