mirror of
https://github.com/thiloho/thiloho.github.io.git
synced 2025-11-22 02:11:35 +01:00
Initialize project with general functionality
This commit is contained in:
29
src/pages/blog/index.astro
Normal file
29
src/pages/blog/index.astro
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
import PageLayout from "../../layouts/PageLayout.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import Date from "../../components/Date.astro";
|
||||
|
||||
const allArticles = await getCollection("blog");
|
||||
const sortedArticles = allArticles.sort((a, b) => {
|
||||
return b.data.pubDate.valueOf() - a.data.pubDate.valueOf();
|
||||
});
|
||||
---
|
||||
|
||||
<PageLayout title="Blog" metaDescription="Blog">
|
||||
<ul>
|
||||
{
|
||||
sortedArticles.map((article) => (
|
||||
<li class="gap-1">
|
||||
<Date date={article.data.pubDate} />
|
||||
<span>»</span>
|
||||
<a
|
||||
class="text-blue-800 hover:no-underline"
|
||||
href={`/blog/${article.id}`}
|
||||
>
|
||||
{article.data.title}
|
||||
</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</PageLayout>
|
||||
Reference in New Issue
Block a user