feat: improve feeds

This commit is contained in:
Cory Dransfeldt 2024-11-15 16:53:25 -08:00
parent a71e910482
commit 1d185fe7cd
No known key found for this signature in database
7 changed files with 62 additions and 46 deletions

10
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "3.2.0", "version": "3.3.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "coryd.dev", "name": "coryd.dev",
"version": "3.2.0", "version": "3.3.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@11ty/eleventy-fetch": "4.0.1", "@11ty/eleventy-fetch": "4.0.1",
@ -1674,9 +1674,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.5.61", "version": "1.5.62",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.61.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.62.tgz",
"integrity": "sha512-CcRGSBCBB6L9c3PBJWYYrBo6Bzeoi+GZTKvtuRtooJGWsINk+mOInZWcssU35zDTAwreVcrMimc9aMyPpehRNw==", "integrity": "sha512-t8c+zLmJHa9dJy96yBZRXGQYoiCEnHYgFwn1asvSPZSUdVxnB62A4RASd7k41ytG3ErFBA0TpHlKg9D9SQBmLg==",
"dev": true, "dev": true,
"license": "ISC" "license": "ISC"
}, },

View file

@ -1,6 +1,6 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "3.2.0", "version": "3.3.0",
"description": "The source for my personal site. Built using 11ty (and other tools).", "description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module", "type": "module",
"engines": { "engines": {

View file

@ -3,12 +3,12 @@ WITH feed_data AS (
SELECT SELECT
p.date AS content_date, p.date AS content_date,
p.title, p.title,
p.description, p.content AS description,
CONCAT('https://coryd.dev', p.url) AS url, CONCAT('https://coryd.dev', p.url) AS url,
NULL AS image, NULL AS image,
NULL AS rating, NULL AS rating,
p.tags, p.tags,
json_build_object('title', p.title, 'url', CONCAT('https://coryd.dev', p.url), 'description', p.description, 'date', p.date) AS feed json_build_object('title', p.title, 'url', CONCAT('https://coryd.dev', p.url), 'description', p.content, 'date', p.date) AS feed
FROM FROM
optimized_posts p optimized_posts p
UNION ALL UNION ALL
@ -20,41 +20,49 @@ WITH feed_data AS (
NULL AS image, NULL AS image,
NULL AS rating, NULL AS rating,
l.tags, l.tags,
json_build_object('title', l.title, 'url', l.link, 'description', l.description, 'date', l.date) AS feed json_build_object('title', CONCAT(l.title, ' via ', l.name), 'url', l.link, 'description', l.description, 'date', l.date) AS feed
FROM FROM
optimized_links l optimized_links l
UNION ALL UNION ALL
SELECT SELECT
b.date_finished AS content_date, b.date_finished AS content_date,
b.title, b.title,
b.description, b.description,
CONCAT('https://coryd.dev', b.url) AS url, CONCAT('https://coryd.dev', b.url) AS url,
b.image, b.image,
b.rating, b.rating,
b.tags, b.tags,
CASE WHEN LOWER(b.status) = 'finished' THEN CASE WHEN LOWER(b.status) = 'finished' THEN
json_build_object('title', b.title, 'url', CONCAT('https://coryd.dev', b.url), 'description', b.description, 'image', b.image, 'rating', b.rating, 'date', b.date_finished) json_build_object('title', b.title, 'url', CONCAT('https://coryd.dev', b.url), 'description', CASE WHEN b.review IS NOT NULL THEN
ELSE b.review
NULL ELSE
END AS feed b.description
FROM END, 'image', b.image, 'rating', b.rating, 'date', b.date_finished)
optimized_books b ELSE
UNION ALL NULL
SELECT END AS feed
m.last_watched AS content_date, FROM
m.title, optimized_books b
m.description, UNION ALL
CONCAT('https://coryd.dev', m.url) AS url, SELECT
m.image, m.last_watched AS content_date,
m.rating, m.title,
m.tags, m.description,
CASE WHEN m.last_watched IS NOT NULL THEN CONCAT('https://coryd.dev', m.url) AS url,
json_build_object('title', m.title, 'url', CONCAT('https://coryd.dev', m.url), 'description', m.description, 'image', m.image, 'rating', m.rating, 'date', m.last_watched) m.image,
ELSE m.rating,
NULL m.tags,
END AS feed CASE WHEN m.last_watched IS NOT NULL THEN
FROM json_build_object('title', m.title, 'url', CONCAT('https://coryd.dev', m.url), 'description', CASE WHEN m.review IS NOT NULL THEN
optimized_movies m m.review
ELSE
m.description
END, 'image', m.image, 'rating', m.rating, 'date', m.last_watched)
ELSE
NULL
END AS feed
FROM
optimized_movies m
) )
SELECT SELECT
json_agg(feed_data.* ORDER BY feed_data.content_date DESC) AS feed json_agg(feed_data.* ORDER BY feed_data.content_date DESC) AS feed

View file

@ -78,7 +78,11 @@ json_build_object('title', CONCAT(b.title, ' by ', b.author), 'image', CONCAT('/
END) AS grid, END) AS grid,
CASE WHEN LOWER(b.read_status) = 'finished' CASE WHEN LOWER(b.read_status) = 'finished'
AND b.star_rating IS NOT NULL THEN AND b.star_rating IS NOT NULL THEN
json_build_object('title', b.title, 'url', CONCAT('https://coryd.dev', b.slug), 'date', b.date_finished, 'description', b.description, 'image', CONCAT('/', df.filename_disk), 'rating', b.star_rating) json_build_object('title', b.title, 'url', CONCAT('https://coryd.dev', b.slug), 'date', b.date_finished, 'description', CASE WHEN b.review IS NOT NULL THEN
b.review
ELSE
b.description
END, 'image', CONCAT('/', df.filename_disk), 'rating', b.star_rating)
ELSE ELSE
NULL NULL
END AS feed END AS feed

View file

@ -83,7 +83,11 @@ WHERE
r.movies_id = m.id) AS related_movies, r.movies_id = m.id) AS related_movies,
CASE WHEN m.star_rating IS NOT NULL CASE WHEN m.star_rating IS NOT NULL
AND m.last_watched IS NOT NULL THEN AND m.last_watched IS NOT NULL THEN
json_build_object('title', m.title, 'url', CONCAT('https://coryd.dev', m.slug), 'date', m.last_watched, 'description', m.description, 'image', CONCAT('/', df.filename_disk), 'rating', m.star_rating) json_build_object('title', m.title, 'url', CONCAT('https://coryd.dev', m.slug), 'date', m.last_watched, 'description', CASE WHEN m.review IS NOT NULL THEN
m.review
ELSE
m.description
END, 'image', CONCAT('/', df.filename_disk), 'rating', m.star_rating)
ELSE ELSE
NULL NULL
END AS feed END AS feed

View file

@ -45,14 +45,14 @@
<xsl:for-each select="/rss/channel/item"> <xsl:for-each select="/rss/channel/item">
<div class="item"> <div class="item">
<time>Published: <xsl:value-of select="pubDate" /></time> <time>Published: <xsl:value-of select="pubDate" /></time>
<h3> <h2>
<a> <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="link" /> <xsl:value-of select="link" />
</xsl:attribute> </xsl:attribute>
<xsl:value-of select="title" /> <xsl:value-of select="title" />
</a> </a>
</h3> </h2>
<xsl:value-of select="description" disable-output-escaping="yes" /> <xsl:value-of select="description" disable-output-escaping="yes" />
<xsl:if test="enclosure"> <xsl:if test="enclosure">
<img class="image-banner" src="{enclosure/@url}" alt="{title}" /> <img class="image-banner" src="{enclosure/@url}" alt="{title}" />

View file

@ -14,7 +14,7 @@
font-size: var(--font-size-sm); font-size: var(--font-size-sm);
} }
& h3 { & h2 {
margin-top: 0; margin-top: 0;
} }