chore: schemas, styles, cleanup

This commit is contained in:
Cory Dransfeldt 2024-10-14 16:43:11 -07:00
parent e0c0c5ccd2
commit 7caf3370ff
No known key found for this signature in database
17 changed files with 123 additions and 55 deletions

View file

@ -42,8 +42,19 @@ const sortBooksByYear = (books) => {
return Object.values(years).filter(year => year['value'] > 2017)
}
const currentYear = new Date().getFullYear()
export default async function () {
const books = await fetchAllBooks()
const sortedByYear = sortBooksByYear(books)
const booksForCurrentYear = sortedByYear.find(
yearGroup => yearGroup.value === currentYear
)?.data || []
return { all: books, years: sortBooksByYear(books), feed: books.filter(book => book['feed']) }
return {
all: books,
years: sortedByYear,
currentYear: booksForCurrentYear,
feed: books.filter(book => book['feed'])
}
}