Recent Blog Posts


See full post archive ...


The Code For This Page:

This is src/pages/blog.astro which is generated from markdown files located in src/pages/posts/ using:

---
import BaseLayout from '../layouts/BaseLayout.astro';
import { Markdown } from 'astro/components'
let allPosts = Astro.fetchContent('../pages/posts/*.md');
allPosts.sort((a, b) => new Date(b.date) - new Date(a.date));
---
<div>
{allPosts.slice(0, 5).map((post) => (
<article>
<a href={post.url}><h3>{post.title}</h3></a>
<p>{post.url}</p>
<p>{post.description}</p>
<p>{new Date(post.date).toISOString().slice(0, 10)}</p>
<a href={post.url}>Read more</a>
</article>
))}
</div>