Fork of Chiri for Astro for my blog
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 19 lines 656 B view raw
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}