fix: no authors
This commit is contained in:
parent
d0fde62431
commit
ec725aefaa
2 changed files with 9 additions and 4 deletions
|
@ -32,6 +32,7 @@ export default {
|
||||||
macos: '#macOS #Apple',
|
macos: '#macOS #Apple',
|
||||||
mastodon: '#Mastodon',
|
mastodon: '#Mastodon',
|
||||||
music: '#Music',
|
music: '#Music',
|
||||||
|
mystery: '#Mystery',
|
||||||
nonfiction: '#NonFiction',
|
nonfiction: '#NonFiction',
|
||||||
politics: '#Politics',
|
politics: '#Politics',
|
||||||
privacy: '#Privacy',
|
privacy: '#Privacy',
|
||||||
|
|
|
@ -3,10 +3,14 @@ const require = createRequire(import.meta.url)
|
||||||
const books = require('./json/read.json')
|
const books = require('./json/read.json')
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
return books.map(book => (
|
return books.map(book => {
|
||||||
{
|
let authors = ''
|
||||||
|
if (book['authors']?.length > 1) authors = book['authors'].join(', ')
|
||||||
|
if (book['authors']?.length === 1) authors = book['authors'][0]
|
||||||
|
|
||||||
|
return {
|
||||||
title: book['title'],
|
title: book['title'],
|
||||||
authors: book['authors'].length > 1 ? book['authors'].join(', ') : book['authors'][0],
|
authors,
|
||||||
description: book['description'],
|
description: book['description'],
|
||||||
image: `https://coryd.dev/.netlify/images/?url=${encodeURIComponent(book['thumbnail'].replace('&edge=curl', ''))}&fit=cover&w=200&h=307`,
|
image: `https://coryd.dev/.netlify/images/?url=${encodeURIComponent(book['thumbnail'].replace('&edge=curl', ''))}&fit=cover&w=200&h=307`,
|
||||||
url: `https://openlibrary.org/isbn/${book['isbn']}`,
|
url: `https://openlibrary.org/isbn/${book['isbn']}`,
|
||||||
|
@ -15,5 +19,5 @@ export default async function () {
|
||||||
tags: book['tags'],
|
tags: book['tags'],
|
||||||
type: 'book',
|
type: 'book',
|
||||||
}
|
}
|
||||||
))
|
})
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue