This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-eleventy/src/_data/books.js

30 lines
994 B
JavaScript

import { createRequire } from 'module'
const require = createRequire(import.meta.url)
const books = require('./json/read.json')
export default async function () {
return books.map(book => {
let authors = ''
let date = book?.['dateAdded']
if (book['authors']?.length > 1) authors = book['authors'].join(', ')
if (book['authors']?.length === 1) authors = book['authors'][0]
if (book?.['dateStarted']) date = book['dateStarted']
if (book?.['dateFinished']) date = book['dateFinished']
return {
title: book['title'],
authors,
description: book['description'],
image: book['thumbnail'],
url: `https://coryd.dev/books/${book['isbn']}`,
date,
status: book['status'],
tags: book['tags'],
categories: book['categories']?.length > 1 ? book['categories'].join(', ') : book['categories']?.[0],
rating: book['rating'] !== 'unrated' ? book['rating'] : '',
isbn: book['isbn'],
type: 'book',
}
})
}