chore: misc cleanup

This commit is contained in:
Cory Dransfeldt 2024-05-05 16:28:41 -07:00
parent 794ba63876
commit 1806afc9aa
No known key found for this signature in database
6 changed files with 7 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import { createRequire } from 'module' import { createRequire } from 'module'
const require = createRequire(import.meta.url) const require = createRequire(import.meta.url)
const books = require('./json/read.json') const books = require('./json/read.json')

View file

@ -1,11 +1,13 @@
export default async function () { export default async function () {
const { ActivityFeed } = await import('@11ty/eleventy-activity-feed') const { ActivityFeed } = await import('@11ty/eleventy-activity-feed')
const feed = new ActivityFeed() const feed = new ActivityFeed()
feed.addSource('rss', '📝', 'https://coryd.dev/feeds/posts') feed.addSource('rss', '📝', 'https://coryd.dev/feeds/posts')
feed.addSource('rss', '🎥', 'https://coryd.dev/feeds/movies') feed.addSource('rss', '🎥', 'https://coryd.dev/feeds/movies')
feed.addSource('rss', '📖', 'https://coryd.dev/feeds/books') feed.addSource('rss', '📖', 'https://coryd.dev/feeds/books')
feed.addSource('rss', '🔗', 'https://coryd.dev/feeds/links') feed.addSource('rss', '🔗', 'https://coryd.dev/feeds/links')
feed.addSource('rss', '🎧', 'https://coryd.dev/feeds/weekly-artist-chart') feed.addSource('rss', '🎧', 'https://coryd.dev/feeds/weekly-artist-chart')
const entries = feed.getEntries().catch() const entries = feed.getEntries().catch()
const res = await entries const res = await entries
const activity = { posts: [] } const activity = { posts: [] }
@ -19,5 +21,6 @@ export default async function () {
date_published: entry.published, date_published: entry.published,
}) })
}) })
return activity return activity
} }

View file

@ -1,5 +1,3 @@
export const artistCapitalization = (artist) => artistCapitalizationPatches[artist?.toLowerCase()] || artist
const sanitizeMediaString = (string) => string.normalize('NFD').replace(/[\u0300-\u036f\u2010—\.\?\(\)\[\]\{\}]/g, '').replace(/\.{3}/g, '') const sanitizeMediaString = (string) => string.normalize('NFD').replace(/[\u0300-\u036f\u2010—\.\?\(\)\[\]\{\}]/g, '').replace(/\.{3}/g, '')
const artistSanitizedKey = (artist) => `${sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase()}` const artistSanitizedKey = (artist) => `${sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase()}`
const albumSanitizedKey = (artist, album) => `${sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase()}-${sanitizeMediaString(album.replace(/[:\/\\,'']+/g const albumSanitizedKey = (artist, album) => `${sanitizeMediaString(artist).replace(/\s+/g, '-').toLowerCase()}-${sanitizeMediaString(album.replace(/[:\/\\,'']+/g

View file

@ -6,5 +6,6 @@ export default async function () {
const artists = JSON.parse(await readFile('./src/_data/json/artists-map.json', 'utf8')); const artists = JSON.parse(await readFile('./src/_data/json/artists-map.json', 'utf8'));
const albums = JSON.parse(await readFile('./src/_data/json/albums-map.json', 'utf8')); const albums = JSON.parse(await readFile('./src/_data/json/albums-map.json', 'utf8'));
const nowPlaying = JSON.parse(await readFile('./src/_data/json/now-playing.json', 'utf8')); const nowPlaying = JSON.parse(await readFile('./src/_data/json/now-playing.json', 'utf8'));
return buildChart(window['data'], artists, albums, nowPlaying) return buildChart(window['data'], artists, albums, nowPlaying)
} }

View file

@ -8,6 +8,7 @@ export default async function () {
const artists = JSON.parse(await readFile('./src/_data/json/artists-map.json', 'utf8')); const artists = JSON.parse(await readFile('./src/_data/json/artists-map.json', 'utf8'));
const albums = JSON.parse(await readFile('./src/_data/json/albums-map.json', 'utf8')); const albums = JSON.parse(await readFile('./src/_data/json/albums-map.json', 'utf8'));
const recent = JSON.parse(await readFile('./src/_data/json/scrobbles-window.json', 'utf8'))['data'].reverse().splice(0,10) const recent = JSON.parse(await readFile('./src/_data/json/scrobbles-window.json', 'utf8'))['data'].reverse().splice(0,10)
return { return {
recent: buildTracksWithArt(recent, artists, albums), recent: buildTracksWithArt(recent, artists, albums),
month: buildChart(monthChart['data'], artists, albums), month: buildChart(monthChart['data'], artists, albums),

View file

@ -7,5 +7,6 @@ export default async function () {
type: 'json', type: 'json',
}).catch() }).catch()
const status = await res const status = await res
return status.response['statuses'][0] return status.response['statuses'][0]
} }