extract post-listing logic

This commit is contained in:
2026-04-05 06:40:18 -04:00
parent e0af57e5b1
commit eda7d3aa00
4 changed files with 20 additions and 12 deletions
+3 -3
View File
@@ -1,12 +1,12 @@
---
import '@styles/prose.css';
import { getCollection, render } from 'astro:content';
import { render } from 'astro:content';
import { listPosts } from '@lib/content.ts';
import BaseLayout from '@layouts/BaseLayout.astro';
// return all posts in dev, only non-draft in prod
let entries = await getCollection('posts', ({ data }) => !data.draft || import.meta.env.DEV );
entries.sort((a, b) => b.data.date.getTime() - a.data.date.getTime());
const entries = await listPosts();
const posts = await Promise.all(entries.map(async entry => {
const { remarkPluginFrontmatter } = await render(entry);
return { ...entry, remarkPluginFrontmatter };