feat: move games into their own section

This commit is contained in:
Devin Haska 2024-11-14 22:32:19 -08:00
parent 6084396e0b
commit fab1780282
35 changed files with 257 additions and 21 deletions

View file

@ -1,3 +1,5 @@
import dayjs from "dayjs";
export const postsByTag = (collection) => {
const posts = collection.getFilteredByTag("post");
@ -13,6 +15,24 @@ export const postsByTag = (collection) => {
return postsByTag;
};
export const gamesByYear = (collection) => {
const allGames = collection.getFilteredByTag("game");
const gamesByYear = {};
allGames.forEach((game) => {
const date = new dayjs(game.date);
const year = date.year();
if (!gamesByYear[year]) {
gamesByYear[year] = { value: year, data: [game] };
} else {
gamesByYear[year].data.push(game);
}
});
return gamesByYear;
};
export const catalogueByType = (collection) => {
const allItems = collection.getFilteredByTag("catalogue");