feat: move books to their own section
This commit is contained in:
parent
8c72d1dd56
commit
db87e0928f
37 changed files with 134 additions and 39 deletions
|
@ -15,24 +15,6 @@ 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");
|
||||
|
||||
|
|
|
@ -29,6 +29,22 @@ export const organizeByDate = (collection) => {
|
|||
return collectionByDate;
|
||||
};
|
||||
|
||||
export const transformByDate = (collection) => {
|
||||
const collectionByDate = {};
|
||||
|
||||
collection.forEach((item) => {
|
||||
const year = formatDate(item.date, "YYYY");
|
||||
|
||||
if (!collectionByDate[year]) {
|
||||
return (collectionByDate[year] = { value: year, data: [item] });
|
||||
}
|
||||
|
||||
collectionByDate[year].data.push(item);
|
||||
});
|
||||
|
||||
return collectionByDate;
|
||||
};
|
||||
|
||||
export const allTagCounts = (collection, ignore = ["post"]) => {
|
||||
if (!collection.length) {
|
||||
throw new Error("Invalid collection, no items");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue