1 import { getCollection, type CollectionEntry } from 'astro:content'
2
3 /**
4 * Get all posts, filtering out posts whose filenames start with _ and static pages
5 */
6 export async function getFilteredPosts() {
7 const posts = await getCollection('posts')
8 const staticPages = ['privacy-policy', 'terms-of-use']
9 return posts.filter((post) => !post.id.startsWith('_') && !staticPages.includes(post.id))
10 }
11
12 /**
13 * Get all posts sorted by publication date, filtering out posts whose filenames start with _
14 */
15 export async function getSortedFilteredPosts() {
16 const posts = await getFilteredPosts()
17 return posts.sort(
18 (a: CollectionEntry<'posts'>, b: CollectionEntry<'posts'>) =>
19 b.data.pubDate.valueOf() - a.data.pubDate.valueOf()
20 )
21 }