import { getCollection } from 'astro:content'; export async function listPosts() { // all posts in dev, exlucde draft posts in prod let entries = await getCollection('posts', ({ data }) => import.meta.env.DEV || !data.draft); // sort by date descending entries.sort((a, b) => b.data.date.getTime() - a.data.date.getTime()); return entries; }