chore: authors in syndication feed; emojis; styles

This commit is contained in:
Cory Dransfeldt 2024-05-22 09:52:06 -07:00
parent 631bd0c2ce
commit a7df0c4fcf
No known key found for this signature in database
5 changed files with 29 additions and 30 deletions

View file

@ -1,3 +1,4 @@
import authors from '../data/author-map.js'
import tagAliases from '../data/tag-aliases.js'
import { DateTime } from 'luxon'
@ -45,12 +46,19 @@ export const allContent = (collection) => {
if (!parsedDate.isValid) parsedDate = DateTime.fromFormat(date, 'dd-MM-yyyy')
return parsedDate.isValid ? parsedDate.toISO() : null
}
const authorLookup = (url) => {
if (!url) return null
const urlObject = new URL(url)
const baseUrl = urlObject.origin
return authors?.[baseUrl] || null
}
const addContent = (items, icon, getTitle, getDate) => {
if (items) {
items.forEach(item => {
const author = authorLookup(item.data?.link)
const content = {
url: item.url?.includes('http') ? item.url : `https://coryd.dev${item.url}`,
title: `${icon}: ${getTitle(item)}`
title: `${icon}: ${getTitle(item)}${author ? ' via ' + author : ''}`
}
if (item.data?.link) content.url = item.data?.link
if (item.data?.description) content.description = `${item.data.description}<br/><br/>`