mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
feat: allow showing featured posts
This commit is contained in:
@@ -7,19 +7,21 @@ export const formatPosts = (
|
||||
{
|
||||
removeDrafts = true,
|
||||
removeFuture = true,
|
||||
showFeatured,
|
||||
sortBy = 'date',
|
||||
sortOrder = 'desc',
|
||||
limit,
|
||||
}: {
|
||||
removeDrafts?: boolean;
|
||||
removeFuture?: boolean;
|
||||
showFeatured?: boolean;
|
||||
sortBy?: 'date' | 'alphabet' | 'random';
|
||||
sortOrder?: 'asc' | 'desc';
|
||||
limit?: number;
|
||||
}
|
||||
): CollectionEntry<'journal'>[] => {
|
||||
const filteredPosts = posts.reduce((acc: CollectionEntry<'journal'>[], post) => {
|
||||
const { date, draft } = post.data;
|
||||
const { date, draft, featured } = post.data;
|
||||
|
||||
// Remove draft content
|
||||
if (removeDrafts && draft) return acc;
|
||||
@@ -27,6 +29,9 @@ export const formatPosts = (
|
||||
// Remove future content
|
||||
if (removeFuture && new Date(date) > new Date()) return acc;
|
||||
|
||||
// Show featured only
|
||||
if (showFeatured && !featured) return acc;
|
||||
|
||||
acc.push(post);
|
||||
|
||||
return acc;
|
||||
|
||||
Reference in New Issue
Block a user