extract post-listing logic
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user