diff --git a/config/collections/index.js b/config/collections/index.js index 3781a944..0452d2dd 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -32,11 +32,23 @@ export const processContent = (collection) => { const parseDate = (date) => { if (!date) return null - let parsedDate = DateTime.fromISO(date) - if (!parsedDate.isValid) parsedDate = DateTime.fromFormat(date, 'yyyy-MM-dd') - if (!parsedDate.isValid) parsedDate = DateTime.fromFormat(date, 'MM/dd/yyyy') - if (!parsedDate.isValid) parsedDate = DateTime.fromFormat(date, 'dd-MM-yyyy') - return parsedDate.isValid ? parsedDate : null + + const formats = [ + { method: 'fromISO' }, + { method: 'fromFormat', format: 'yyyy-MM-dd' }, + { method: 'fromFormat', format: 'MM/dd/yyyy' }, + { method: 'fromFormat', format: 'dd-MM-yyyy' }, + ] + + for (const { method, format } of formats) { + const parsedDate = format + ? DateTime[method](date, format) + : DateTime[method](date) + + if (parsedDate.isValid) return parsedDate + } + + return null } const addSiteMapContent = (items, getTitle, getDate) => { diff --git a/config/filters/feeds.js b/config/filters/feeds.js index d6ecb807..f1e2a52f 100644 --- a/config/filters/feeds.js +++ b/config/filters/feeds.js @@ -12,79 +12,67 @@ export default { const posts = [] const mdGenerator = () => { const md = markdownIt({ html: true, linkify: true }) - md.use(markdownItAnchor, { level: [1, 2], - permalink: markdownItAnchor.permalink.headerLink({ - safariReaderFix: true - }) + permalink: markdownItAnchor.permalink.headerLink({ safariReaderFix: true }) }) md.use(markdownItFootnote) - md.renderer.rules.footnote_ref = (tokens, idx) => { - const id = tokens[idx].meta.id + 1 - return `${id}` - } - md.renderer.rules.footnote_block_open = () => ( - '
\n
\n
    \n' - ) - md.renderer.rules.footnote_open = (tokens, idx) => { - const id = tokens[idx].meta.id + 1 - return `
  1. ` - } + md.renderer.rules.footnote_ref = (tokens, idx) => `${tokens[idx].meta.id + 1}` + md.renderer.rules.footnote_block_open = () => '
    \n
    \n
      \n' + md.renderer.rules.footnote_open = (tokens, idx) => `
    1. ` md.renderer.rules.footnote_anchor = () => '' return md } - const entryData = limit ? entries.slice(0, limit) : entries + const entryData = limit ? entries.slice(0, limit) : entries entryData.forEach((entry) => { const md = mdGenerator() const dateKey = Object.keys(entry).find(key => key.includes('date')) - let { artist, authors, backdrop, content, description, image, link, rating, review, slug, title, url, tags, type } = entry + const { + artist, authors, backdrop, content, description, image, link, rating, review, + slug, title, url, tags, type + } = entry + + const processedEntry = { + title: title.trim(), + date: new Date(entry[dateKey]), + content: description || '' + } const feedNote = '

      This is a full text feed, but not all content can be rendered perfectly within the feed. If something looks off, feel free to visit my site for the original post.

      ' - const processedEntry = { title: title.trim(), date: new Date(entry[dateKey]), content: description } - if (url?.includes('http')) processedEntry['url'] = url - if (!url?.includes('http')) processedEntry['url'] = new URL(url, BASE_URL).toString() - if (slug) processedEntry['url'] = new URL(slug, BASE_URL).toString() + processedEntry.url = (url?.includes('http')) ? url : new URL(slug || url, BASE_URL).toString() + if (link) { - processedEntry['title'] = `${title} via ${authors['name']}` - processedEntry['url'] = link, - processedEntry['author'] = { - name: authors['name'], - url: authors['url'], - mastodon: authors?.['mastodon'] || '', - rss: authors?.['rss_feed'] || '' - }, - processedEntry['excerpt'] = sanitizeHtml(`${md.render(description)}`) - } - if (description) processedEntry['excerpt'] = description - if (['book', 'movie'].includes(type) && review) { - processedEntry['excerpt'] = sanitizeHtml(`${md.render(review)}`) + processedEntry.title = `${title} via ${authors?.name || 'Unknown'}` + processedEntry.url = link + processedEntry.author = { + name: authors?.name || 'Unknown', + url: authors?.url || '', + mastodon: authors?.mastodon || '', + rss: authors?.rss_feed || '' + } + processedEntry.excerpt = sanitizeHtml(md.render(description || '')) } else if (['book', 'movie'].includes(type)) { - processedEntry['excerpt'] = sanitizeHtml(`${md.render(description)}`) + processedEntry.excerpt = sanitizeHtml(md.render(review || description || '')) + } else if (type === 'album-release') { + let sanitizedDescription = sanitizeHtml(md.render(description || '')) + let truncatedDescription = truncate(sanitizedDescription, { length: 500, reserveLastWord: true, ellipsis: '...' }) + if (sanitizedDescription.length > 500) truncatedDescription += ` Read more about ${artist?.name}` + processedEntry.excerpt = truncatedDescription + } else if (slug && content) { + processedEntry.excerpt = sanitizeHtml(md.render(content) + feedNote, { disallowedTagsMode: 'completelyDiscard' }) + } else if (description) { + processedEntry.excerpt = 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 += ` Read more about ${entry['artist']['name']}` - processedEntry['excerpt'] = truncatedDescription - } - if (slug && content) processedEntry['excerpt'] = sanitizeHtml(`${md.render(content)}${feedNote}`, { - disallowedTagsMode: 'completelyDiscard' - }) - processedEntry['image'] = backdrop || image + processedEntry.image = backdrop || image - if (rating) processedEntry['rating'] = rating - if (tags) processedEntry['tags'] = tags - if (type === 'album-release' && artist) processedEntry['title'] = `${title} by ${artist}` + 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) + posts.push(processedEntry) }) return posts diff --git a/package-lock.json b/package-lock.json index 5e6fb046..46ef9bf0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "24.19.5", + "version": "24.19.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "24.19.5", + "version": "24.19.7", "license": "MIT", "dependencies": { "@cdransf/api-text": "^1.5.0", @@ -701,9 +701,9 @@ "peer": true }, "node_modules/@types/node": { - "version": "22.5.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", - "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", + "version": "22.6.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.6.1.tgz", + "integrity": "sha512-V48tCfcKb/e6cVUigLAaJDAILdMP0fUW6BidkPK4GpGjXcfbnoHasCZDwz3N3yVt5we2RHm4XTQCpv0KJz9zqw==", "dev": true, "license": "MIT", "dependencies": { @@ -1083,9 +1083,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001662", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001662.tgz", - "integrity": "sha512-sgMUVwLmGseH8ZIrm1d51UbrhqMCH3jvS7gF/M6byuHOnKyLOBL7W8yz5V02OHwgLGA36o/AFhWzzh4uc5aqTA==", + "version": "1.0.30001663", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001663.tgz", + "integrity": "sha512-o9C3X27GLKbLeTYZ6HBOLU1tsAcBZsLis28wrVzddShCS16RujjHp9GDHKZqrB3meE0YjhawvMFsGb/igqiPzA==", "dev": true, "funding": [ { @@ -2651,9 +2651,9 @@ } }, "node_modules/jackspeak": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", - "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -2664,9 +2664,6 @@ }, "funding": { "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/js-yaml": { diff --git a/package.json b/package.json index 36218584..99baef7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "24.19.5", + "version": "24.19.7", "description": "The source for my personal site. Built using 11ty (and other tools).", "type": "module", "scripts": { diff --git a/src/assets/styles/components/music-chart.css b/src/assets/styles/components/music-chart.css index e8c4338f..f310e786 100644 --- a/src/assets/styles/components/music-chart.css +++ b/src/assets/styles/components/music-chart.css @@ -27,7 +27,7 @@ } &:not(:last-of-type) { - margin-bottom: var(--spacing-md); + margin-bottom: var(--spacing-lg); } & .progress-bar-wrapper { diff --git a/src/pages/dynamic/music/artists/artist.html b/src/pages/dynamic/music/artists/artist.html index e78ba79e..d75e19a8 100644 --- a/src/pages/dynamic/music/artists/artist.html +++ b/src/pages/dynamic/music/artists/artist.html @@ -48,7 +48,7 @@ schema: artist

      {% tablericon "needle" "Tattoo" %} I have a tattoo inspired by this artist!

      {%- endif -%} {%- if artist.totalPlays > 0 -%} -

      {{ artist.totalPlays }} {{ playLabel }}

      +

      {{ artist.totalPlays | formatNumber }} {{ playLabel }}

      {%- endif -%}