diff --git a/_posts/hello-world.md b/_posts/hello-world.md index d35a142..39427ea 100644 --- a/_posts/hello-world.md +++ b/_posts/hello-world.md @@ -1,6 +1,6 @@ --- title: Hello, World! -date: 2023-03-02 +date: 2024-03-02 excerpt: DVDA Games is part wannabe indie game studio and part open-source tool developer. coverImage: /assets/blog/hello-world/cover.jpg @@ -10,6 +10,7 @@ author: ogImage: url: /assets/blog/hello-world/cover.jpg preview: false +featured: true --- Dead Villager Dead Adventurer (DVDA) Games is named for those fallen souls in the [Diablo games](https://en.wikipedia.org/wiki/Diablo_%28video_game%29) who gave their lives in pursuit of adventure or were just unfortunate enough to encounter the horrors outside of the relative safety of the town. diff --git a/src/interfaces/post.ts b/src/interfaces/post.ts index e2da990..1ca88ba 100644 --- a/src/interfaces/post.ts +++ b/src/interfaces/post.ts @@ -12,4 +12,5 @@ export type Post = { }; content: string; preview?: boolean; + featured?: boolean; }; diff --git a/src/lib/api.ts b/src/lib/api.ts index 904a3f1..88c682e 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -25,9 +25,17 @@ export function getPostBySlug(slug: string) { export function getAllPosts(): Post[] { const slugs = getPostSlugs(); + + const featuredPosts = slugs + .map((slug) => getPostBySlug(slug)) + .filter((post) => post.featured) + .sort((post1, post2) => (post1.date > post2.date ? -1 : 1)); + const posts = slugs .map((slug) => getPostBySlug(slug)) + .filter((post) => !post.featured) // sort posts by date in descending order .sort((post1, post2) => (post1.date > post2.date ? -1 : 1)); - return posts; + + return [...featuredPosts, ...posts]; }