chore: cleanup

This commit is contained in:
Cory Dransfeldt 2024-09-16 07:56:25 -07:00
parent ade57be4a5
commit de2dca0810
No known key found for this signature in database
10 changed files with 311 additions and 37 deletions

View file

@ -87,6 +87,8 @@ export const processContent = (collection) => {
items.forEach((item) => {
let attribution
let hashTags = tagsToHashtags(item) ? ' ' + tagsToHashtags(item) : ''
if (item['type'] === 'album-release') hashTags = ' #Music #NewMusic'
if (item['type'] === 'concert') hashTags = ' #Music #Concert'
// link attribution if properties exist
if (item?.['authors']?.['mastodon']) {
@ -108,6 +110,8 @@ export const processContent = (collection) => {
// set url for posts - identified as slugs here
if (item?.['slug']) content['url'] = new URL(item['slug'], BASE_URL).toString()
// set unique concert urls
if (item?.['type'] === 'concert') content['url'] = `${item['artistUrl']}?t=${DateTime.fromISO(item['date']).toMillis()}#concerts`
if (item?.['description']) {
content['description'] = `${item['description'].split(' ').length >= 25 ? item['description'].split(' ').slice(0, 25).join(' ') + '...' : item['description']}`
} else if (item?.['notes']) {
@ -135,6 +139,8 @@ export const processContent = (collection) => {
addContent(links, '🔗', (item) => item['title'], (item) => item['date'])
addContent(books.all.filter((book) => book['status'] === 'finished'), '📖', (item) => `${item['title']}${item['rating'] ? ' (' + item['rating'] + ')' : ''}`, (item) => item['date'])
addContent(movies['movies'], '🎥', (item) => `${item['title']}${item['rating'] ? ' (' + item['rating'] + ')' : ''}`, (item) => item['lastWatched'])
addContent(concerts, '🎤', (item) => `${item['artistNameString'] ? item['artistNameString'] : item['artist']['name']} at ${item['venue']['name'].split(',')[0].trim()}`, (item) => item['date'])
addContent([...albumReleases['current']].reverse(), '📆', (item) => `${item['title']} by ${item['artist']['name']}`, (item) => item['release_date'])
addSiteMapContent(posts, (item) => item.title, (item) => item.date)
addSiteMapContent(pages, (item) => item.title, (item) => item.date)
@ -173,10 +179,10 @@ export const albumReleasesCalendar = (collection) => {
start: [date.year, date.month, date.day],
startInputType: 'local',
startOutputType: 'local',
title: `Release: ${album.artist} - ${album.title}`,
description: `Check out this new album release: ${album.url}`,
title: `Release: ${album['artist']['name']} - ${album['title']}`,
description: `Check out this new album release: ${album['url']}. Read more about ${album['artist']['name']} at https://coryd.dev${album['artist']['url']}`,
url: album.url,
uid: `${date.toFormat('yyyyMMdd')}-${album.artist}-${album.title}@coryd.dev`,
uid: `${date.toFormat('yyyyMMdd')}-${album['artist']['name']}-${album.title}@coryd.dev`,
timestamp: DateTime.now().toUTC().toFormat("yyyyMMdd'T'HHmmss'Z'")
}
}).filter(event => event !== null)

View file

@ -3,6 +3,7 @@ import markdownIt from 'markdown-it'
import markdownItAnchor from 'markdown-it-anchor'
import markdownItFootnote from 'markdown-it-footnote'
import sanitizeHtml from 'sanitize-html'
import truncate from 'truncate-html'
const BASE_URL = 'https://coryd.dev'
@ -63,6 +64,16 @@ export default {
} else if (['book', 'movie'].includes(type)) {
processedEntry['excerpt'] = sanitizeHtml(`${md.render(description)}`)
}
if (type === 'album-release') {
let sanitizedDescription = sanitizeHtml(`${md.render(description)}`)
let truncatedDescription = truncate(sanitizedDescription, {
length: 500,
reserveLastWord: true,
ellipsis: '...'
})
if (sanitizedDescription.length > 500) truncatedDescription += ` <a href="${entry['artist']['url']}">Read more about ${entry['artist']['name']}</a>`
processedEntry['excerpt'] = truncatedDescription
}
if (slug && content) processedEntry['excerpt'] = sanitizeHtml(`${md.render(content)}${feedNote}`, {
disallowedTagsMode: 'completelyDiscard'
})
@ -71,6 +82,8 @@ export default {
if (rating) processedEntry['rating'] = rating
if (tags) processedEntry['tags'] = tags
if (type === 'album-release' && artist) processedEntry['title'] = `${title} by ${artist}`
if (entry) posts.push(processedEntry)
})

View file

@ -28,8 +28,8 @@ export default {
break
case 'album-release':
normalized.title = item['title']
normalized.alt = `${item['title']} by ${item['artist']}`
normalized.subtext = `${item['artist']} / ${item['date']}`
normalized.alt = `${item['title']} by ${item['artist']['name']}`
normalized.subtext = `${item['artist']['name']} / ${item['date']}`
break
case 'movie':
normalized.title = item['title']