Skip to content

Commit

Permalink
Merge branch 'announcement-post' of https://github.com/astrolicious/d…
Browse files Browse the repository at this point in the history
…otdev into announcement-post
  • Loading branch information
alexanderniebuhr committed Sep 24, 2024
2 parents cba4d43 + eee94e7 commit 829082b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions apps/site/src/pages/blog/index.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---
import { getCollection } from 'astro:content';
import ArticleCard from '~/components/ArticleCard.astro';
import Layout from '~/layouts/Layout.astro';
import { getCollection } from "astro:content";
import ArticleCard from "~/components/ArticleCard.astro";
import Layout from "~/layouts/Layout.astro";
const title = 'Articles';
const articles = await getCollection('blog', ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true;
const title = "Articles";
const sortedArticles = (
await getCollection("blog", ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true;
})
).sort((a, b) => {
return b.data.publishDate.getTime() - a.data.publishDate.getTime();
});
---

Expand All @@ -16,8 +20,8 @@ const articles = await getCollection('blog', ({ data }) => {
>
{title}
</h1>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2 mt-8">
{articles.map((article) => <ArticleCard {article} />)}
<div class="grid grid-cols-1 gap-4 mt-8">
{sortedArticles.map((article) => <ArticleCard {article} />)}
</div>
</div>
</Layout>

0 comments on commit 829082b

Please sign in to comment.