---
import BaseLayout from '../layouts/BaseLayout.astro';
import { getCollection, getEntry } from 'astro:content';

const pageTitle = 'blog';
const posts = await getCollection('posts');
console.log(posts)
const allPosts = Object.values(import.meta.glob('./posts/*.md', { eager: true }));
allPosts.sort((a, b) => new Date(b.frontmatter.pubDate) - new Date(a.frontmatter.pubDate));
---

<BaseLayout pageTitle={pageTitle}>
	<p>ITT: the incoherent ramblings of an emo madman with a technological inclination.</p>

	<hr>

	<div style="text-align: left;">
		<h2>posts</h2>
		<ul>
			{allPosts.map((post: any) => <li><a href={post.url}>{post.frontmatter.title}</a> — <em>published on {post.frontmatter.pubDate.toString().slice(0, 10)}</em></li>)}
		</ul>
	</div>
</BaseLayout>
