aboutsummaryrefslogtreecommitdiff
path: root/src/pages/blog/index.astro
blob: 1614f2f8d0ba285772634f673dbdee581492febe (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/Page.astro";
import { getCollection } from "astro:content";
import {formatDate} from "../../util";

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

   </main>
</Page>
<style>
   h1 {
      margin-top: 2px;
      margin-bottom: 2px;
   }

   article {
      background-color: #3B513B;
      padding: 1.2em;
      border-radius: 20px;
      gap: 0.5em;
      margin: 0.5em;
   }

   main {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
   }

   /* Mobile view */
   @media (max-width: 992px) {
      main {
         grid-template-columns: 1fr;
      }
   }
</style>