feat: associate books and artists

This commit is contained in:
Cory Dransfeldt 2024-08-23 17:04:36 -07:00
parent 40ad47aacb
commit fdf0ebf2ca
No known key found for this signature in database
12 changed files with 97 additions and 28 deletions

34
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "coryd.dev",
"version": "22.5.3",
"version": "22.6.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "coryd.dev",
"version": "22.5.3",
"version": "22.6.0",
"license": "MIT",
"dependencies": {
"@cdransf/api-text": "^1.5.0",
@ -20,10 +20,10 @@
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"@11tyrocks/eleventy-plugin-lightningcss": "^1.4.0",
"@cdransf/eleventy-plugin-tabler-icons": "^1.11.0",
"@supabase/supabase-js": "^2.45.1",
"@supabase/supabase-js": "^2.45.2",
"dotenv-flow": "^4.1.0",
"ics": "^3.7.6",
"liquidjs": "^10.16.3",
"liquidjs": "^10.16.4",
"luxon": "^3.5.0",
"markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.0.1",
@ -443,9 +443,9 @@
}
},
"node_modules/@supabase/storage-js": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.6.0.tgz",
"integrity": "sha512-REAxr7myf+3utMkI2oOmZ6sdplMZZ71/2NEIEMBZHL9Fkmm3/JnaOZVSRqvG4LStYj2v5WhCruCzuMn6oD/Drw==",
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.7.0.tgz",
"integrity": "sha512-iZenEdO6Mx9iTR6T7wC7sk6KKsoDPLq8rdu5VRy7+JiT1i8fnqfcOr6mfF2Eaqky9VQzhP8zZKQYjzozB65Rig==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -453,9 +453,9 @@
}
},
"node_modules/@supabase/supabase-js": {
"version": "2.45.1",
"resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.45.1.tgz",
"integrity": "sha512-/PVe3lXmalazD8BGMIoI7+ttvT1mLXy13lNcoAPtjP1TDDY83g8csZbVR6l+0/RZtvJxl3LGXfTJT4bjWgC5Nw==",
"version": "2.45.2",
"resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.45.2.tgz",
"integrity": "sha512-kJKY3ISFusVKQWCP8Kqo20Ebxy2WLp6Ry/Suco0aQsPXH7bvn7clswsdhcfcH/5Tr0MYz/jcCjF0n/27SetiCw==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -464,7 +464,7 @@
"@supabase/node-fetch": "2.6.15",
"@supabase/postgrest-js": "1.15.8",
"@supabase/realtime-js": "2.10.2",
"@supabase/storage-js": "2.6.0"
"@supabase/storage-js": "2.7.0"
}
},
"node_modules/@types/linkify-it": {
@ -2153,9 +2153,9 @@
}
},
"node_modules/liquidjs": {
"version": "10.16.3",
"resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-10.16.3.tgz",
"integrity": "sha512-CbIeSH5zc7nVPFgexN1EQlAxAk2DAQDvIN8r40PHs/HxubhQyEoZS/CgKpd9ax9walAUqk+VpkSR1CfoFr4Nhw==",
"version": "10.16.4",
"resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-10.16.4.tgz",
"integrity": "sha512-5kK5HRZng6crSedS11D1h9Od8pYB5wjWjvJIlbhLVS7n+ITWzQervv27jx+7MkOS2KYfAEhwlEinTsTn4Ae5WQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -2267,9 +2267,9 @@
}
},
"node_modules/micromatch": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz",
"integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==",
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"license": "MIT",
"dependencies": {

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "22.5.3",
"version": "22.6.0",
"description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module",
"scripts": {
@ -35,10 +35,10 @@
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"@11tyrocks/eleventy-plugin-lightningcss": "^1.4.0",
"@cdransf/eleventy-plugin-tabler-icons": "^1.11.0",
"@supabase/supabase-js": "^2.45.1",
"@supabase/supabase-js": "^2.45.2",
"dotenv-flow": "^4.1.0",
"ics": "^3.7.6",
"liquidjs": "^10.16.3",
"liquidjs": "^10.16.4",
"luxon": "^3.5.0",
"markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.0.1",

View file

@ -6,6 +6,10 @@ button,
appearance: none;
border: none;
& + hr {
margin-top: 0;
}
&:not(.theme-toggle) {
border: 2px solid var(--accent-color);
padding: var(--sizing-xs) var(--sizing-md);

View file

@ -112,6 +112,15 @@
p {
margin: var(--sizing-base) 0;
&.music {
color: var(--music);
& svg {
stroke: var(--music);
margin-right: var(--sizing-xs);
}
}
}
}

View file

@ -26,6 +26,15 @@
}
}
& p.books {
color: var(--books);
& svg {
stroke: var(--books);
margin-right: var(--sizing-xs);
}
}
& .artist-display {
display: flex;
flex-direction: column;

View file

@ -27,7 +27,8 @@ const fetchAllArtists = async () => {
tattoo,
art,
albums,
concerts
concerts,
books
`)
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
@ -66,7 +67,14 @@ const processArtists = (artists) => {
totalPlays: album['total_plays'],
art: album.art ? `/${album['art']}` : ''
})).sort((a, b) => a['release_year'] - b['release_year']),
concerts: artist['concerts']?.[0]?.id ? artist['concerts'].sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null
concerts: artist['concerts']?.[0]?.id ? artist['concerts'].sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null,
books: artist['books']?.[0]?.id ? artist['books'].map(book => ({
title: book['title'],
author: book['author'],
isbn: book['isbn'],
description: book['description'],
url: `/books/${book['isbn']}`,
})).sort((a, b) => a['title'].localeCompare(b['title'])) : null
}))
}

View file

@ -1,4 +1,5 @@
import { createClient } from '@supabase/supabase-js'
import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js'
const SUPABASE_URL = process.env.SUPABASE_URL
const SUPABASE_KEY = process.env.SUPABASE_KEY
@ -25,7 +26,8 @@ const fetchAllBooks = async () => {
review,
art,
favorite,
tags
tags,
artists
`)
.order('date_finished', { ascending: false })
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
@ -47,6 +49,11 @@ const processBooks = (books) => {
return books.map(book => {
const dateFinished = new Date(book['date_finished'])
const year = dateFinished.getUTCFullYear()
const artists = book?.['artists']?.map(artist => {
artist['url'] = `/music/artists/${sanitizeMediaString(artist['name'])}-${sanitizeMediaString(parseCountryField(artist['country']))}`
return artist
}).sort((a, b) => a['name'].localeCompare(b['name']))
return {
title: book['title'],
author: book['author'] || '',
@ -59,9 +66,10 @@ const processBooks = (books) => {
date: book['date_finished'],
status: book['read_status'],
progress: book['progress'],
tags: book['tags'] ? book['tags'].split(',') : [],
tags: Array.isArray(book['tags']) ? book['tags'] : book['tags']?.split(',') || [], // Ensure tags is an array
isbn: book['isbn'],
type: 'book',
artists,
year,
}
})

View file

@ -54,6 +54,25 @@ schema: book
{{ book.review | markdown }}
<hr />
{% endif %}
{%- if book.artists -%}
{%- capture sectionTitle -%}
{% if book.artists.size > 1 %}
I listen to artists featured in this book!
{% else %}
I listen to the artist featured in this book!
{%- endif -%}
{%- endcapture -%}
<p id="artists" class="music flex-centered">
{% tablericon "headphones" "Music" %}
{{ sectionTitle }}
</p>
<ul>
{% for artist in book.artists %}
<li><a href="{{ artist.url }}">{{ artist.name }}</a>{%- if artist.total_plays > 0 -%}: <strong class="highlight-text">{{ artist.total_plays }} plays</strong>{%- endif -%}</li>
{% endfor %}
</ul>
<hr />
{%- endif -%}
{% if book.description %}
<h3>Overview</h3>
{{ book.description | markdown }}

View file

@ -11,7 +11,7 @@ schema: books
<h2>Currently reading</h2>
<p>Here's what I'm reading at the moment. I've finished <strong class="highlight-text">{{ currentBookCount }} books</strong> this year.</p>
<p>{{ books.years | bookYearLinks }}</p>
{% render "partials/blocks/banners/rss.liquid", url: "https://coryd.dev/feeds/books", text: "Subscribe to my books feed or follow along on this page" %}
{% render "partials/blocks/banners/rss.liquid", url: "/feeds/books", text: "Subscribe to my books feed or follow along on this page" %}
<hr />
{% for book in bookData %}
{% capture alt %}{{ book.title }} by {{ book.authors }}{% endcapture %}

View file

@ -10,7 +10,7 @@ permalink: "/links/{% if pagination.pageNumber > 0 %}{{ pagination.pageNumber }}
{% if pagination.pageNumber == 0 %}
<h2>Links</h2>
<p>These are links I've liked or otherwise found interesting. They're all added manually, after having been read and, I suppose, properly considered.</p>
{% render "partials/blocks/banners/rss.liquid", url: "https://coryd.dev/feeds/links", text: "Subscribe to my links feed or follow along on this page" %}
{% render "partials/blocks/banners/rss.liquid", url: "/feeds/links", text: "Subscribe to my links feed or follow along on this page" %}
<hr />
{% endif %}
<div class="link-grid">

View file

@ -89,8 +89,20 @@ schema: artist
</li>
{% endfor %}
</ul>
<hr />
{%- endif -%}
{%- if artist.books -%}
<hr />
<p id="books" class="books flex-centered">
{% tablericon "books" "books" %}
I've read about this artist!
</p>
<ul>
{% for book in artist.books %}
<li><a href="{{ book.url }}">{{ book.title }}</a> by {{ book.author }}</li>
{% endfor %}
</ul>
{%- endif -%}
{%- if artist.books or artist.concerts -%}<hr />{%- endif -%}
<table>
<tr>
<th>Album</th>

View file

@ -10,7 +10,7 @@ schema: watching
<h2 class="watching">{{ title }}</h2>
{% render "partials/media/watching/hero.liquid" movie:featuredMovie %}
<p>Here's all of the TV and movies I've been watching presented in what is (hopefully) an organized fashion.</p>
{% render "partials/blocks/banners/rss.liquid", url: "https://coryd.dev/feeds/movies", text: "Subscribe to my movies feed or follow along on this page" %}
{% render "partials/blocks/banners/rss.liquid", url: "/feeds/movies", text: "Subscribe to my movies feed or follow along on this page" %}
<hr />
<h3 id="movies" class="section-header">
<a href="/watching/recent/movies">