forked from
quillmatiq.com/augment
Fork of Chiri for Astro for my blog
1import { getCollection, type CollectionEntry } from 'astro:content'
2
3/**
4 * Get all posts, filtering out posts whose filenames start with _
5 */
6export async function getFilteredPosts() {
7 const posts = await getCollection('posts')
8 return posts.filter((post: CollectionEntry<'posts'>) => !post.id.startsWith('_'))
9}
10
11/**
12 * Get all posts sorted by publication date, filtering out posts whose filenames start with _
13 */
14export async function getSortedFilteredPosts() {
15 const posts = await getFilteredPosts()
16 return posts.sort(
17 (a: CollectionEntry<'posts'>, b: CollectionEntry<'posts'>) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()
18 )
19}