aboutsummaryrefslogtreecommitdiff
path: root/src/pages/blog/index.astro
blob: a35537a32bd744ecccca34d514d29afcdc565349 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
import Page from "../../layouts/Default.astro";
import { getCollection } from "astro:content";
import {formatDate} from "../../util";
import '../../styles/Page.css';
import "../../styles/cards.css";
import {Icon} from "astro-icon/components";

const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
---
<Page title="Blog - Andrew Lee" description="Where I post can be anything!">
   <main>
      <header>
         <h1 class="header-text">
            Blog
            <a href="/blog/rss.xml">
               <Icon name="fa6-solid:square-rss" aria-label="RSS" />
            </a>
         </h1>
         <h2 class="header-text">Where I post can be anything!</h2>
      </header>
      <div class="container">
         <div class="grid">
            {allBlogPosts.map((post) => (
                <article class="card">
                   <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>
            ))
            }
         </div>
      </div>
   </main>
</Page>
<style>
   .tags {
      display: flex;
      flex-direction: row;
      gap: 1em;
   }

</style>