diff --git a/config/collections/index.js b/config/collections/index.js index 2406d3e5..8724d00e 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -50,14 +50,19 @@ export const tagMap = (collection) => { const collectionData = collection.getAll()[0] const posts = collectionData.data.collections.posts const links = collectionData.data.collections.links + const books = collectionData.data.books + if (posts) { posts.forEach((post) => { const url = post.url.includes('http') ? post.url : `https://coryd.dev${post.url}` - const tagString = [...new Set(post.data.tags.map((tag) => tagAliases[tag.toLowerCase()]))] + const tagString = [...new Set(post.data.tags?.map((tag) => tagAliases[tag.toLowerCase()]))] .join(' ') .trim() if (tagString) tags[url] = tagString.replace(/\s+/g,' ') }) + } + + if (links) { links.forEach((link) => { const url = link.data.link const tagString = [...new Set(link.data.tags?.map((tag) => tagAliases[tag.toLowerCase()]))] @@ -66,6 +71,17 @@ export const tagMap = (collection) => { if (tagString) tags[url] = tagString.replace(/\s+/g,' ') }) } + + if (books) { + books.forEach((book) => { + const tagString = book?.['tags'] + .map((tag) => tagAliases[tag.toLowerCase()]) + .join(' ') + .trim() + if (tagString) tags[book.url] = tagString.replace(/\s+/g,' ') + }) + } + return tags } diff --git a/config/data/tag-aliases.js b/config/data/tag-aliases.js index 67f675c5..b2ba16a9 100644 --- a/config/data/tag-aliases.js +++ b/config/data/tag-aliases.js @@ -27,11 +27,13 @@ export default { macos: '#macOS #Apple', mastodon: '#Mastodon', music: '#Music', + nonfiction: '#NonFiction', privacy: '#Privacy', productivity: '#Productivity', react: '#JavaScript', rss: '#RSS', shoegaze: '#Shoegaze', + scifi: '#SciFi', 'social media': '#SocialMedia', spotify: '#Music', 'surveillance capitalism': '#SurveillanceCapitalism', diff --git a/config/filters/index.js b/config/filters/index.js index c714102e..170d9ee7 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -63,7 +63,7 @@ export default { tagLookup: (url, tagMap) => { if (!url) return - if (url.includes('openlibrary.org')) return '#Books #NowReading' + if (url.includes('openlibrary.org')) return `#Books #NowReading ${tagMap[url]}` if (url.includes('trakt.tv')) return '#Movies #Watching #Trakt' return tagMap[url] || '' }, diff --git a/src/_data/books.js b/src/_data/books.js index f2bbe441..bc7c45ba 100644 --- a/src/_data/books.js +++ b/src/_data/books.js @@ -12,6 +12,7 @@ export default async function () { url: `https://openlibrary.org/isbn/${book['isbn']}`, dateAdded: book?.['dateStarted'] || book?.['dateFinished'], status: book['status'], + tags: book['tags'], type: 'book', } ))