From 2dd3d60485bb07394d85aa9fac21e767832ab13d Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Jul 2025 03:16:23 -0700 Subject: [PATCH] fix: update RSS feed to work with new media architecture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update album queries to use media relation instead of direct photos relation - Filter photography albums by checking media.isPhotography instead of album.isPhotography - Remove reference to non-existent post.excerpt field - Fix cover photo access and counts to use album.media - Fix URL concatenation for Cloudinary images to handle absolute URLs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/routes/rss/+server.ts | 56 +++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/routes/rss/+server.ts b/src/routes/rss/+server.ts index 832e368..a8807d3 100644 --- a/src/routes/rss/+server.ts +++ b/src/routes/rss/+server.ts @@ -73,16 +73,15 @@ export const GET: RequestHandler = async (event) => { showInUniverse: true }, include: { - photos: { - where: { - status: 'published', - showInPhotos: true + media: { + include: { + media: true }, orderBy: { displayOrder: 'asc' }, - take: 1 // Get first photo for cover image + take: 1 // Get first media for cover image }, _count: { - select: { photos: true } + select: { media: true } } }, orderBy: { createdAt: 'desc' }, @@ -93,23 +92,34 @@ export const GET: RequestHandler = async (event) => { const photoAlbums = await prisma.album.findMany({ where: { status: 'published', - isPhotography: true + media: { + some: { + media: { + isPhotography: true + } + } + } }, include: { - photos: { + media: { + include: { + media: true + }, where: { - status: 'published', - showInPhotos: true + media: { + isPhotography: true + } }, orderBy: { displayOrder: 'asc' }, take: 1 // Get first photo for cover image }, _count: { select: { - photos: { + media: { where: { - status: 'published', - showInPhotos: true + media: { + isPhotography: true + } } } } @@ -127,7 +137,7 @@ export const GET: RequestHandler = async (event) => { id: post.id.toString(), title: post.title || `${post.postType.charAt(0).toUpperCase() + post.postType.slice(1)} Post`, - description: post.excerpt || extractTextSummary(post.content) || '', + description: extractTextSummary(post.content) || '', content: convertContentToHTML(post.content), link: `${event.url.origin}/universe/${post.slug}`, guid: `${event.url.origin}/universe/${post.slug}`, @@ -143,14 +153,14 @@ export const GET: RequestHandler = async (event) => { title: album.title, description: album.description || - `Photo album with ${album._count.photos} photo${album._count.photos !== 1 ? 's' : ''}`, + `Photo album with ${album._count.media} photo${album._count.media !== 1 ? 's' : ''}`, content: album.description ? `

${escapeXML(album.description)}

` : '', link: `${event.url.origin}/photos/${album.slug}`, guid: `${event.url.origin}/photos/${album.slug}`, pubDate: album.createdAt, updatedDate: album.updatedAt, - photoCount: album._count.photos, - coverPhoto: album.photos[0], + photoCount: album._count.media, + coverPhoto: album.media[0]?.media, location: album.location })), ...photoAlbums @@ -162,14 +172,14 @@ export const GET: RequestHandler = async (event) => { title: album.title, description: album.description || - `Photography album${album.location ? ` from ${album.location}` : ''} with ${album._count.photos} photo${album._count.photos !== 1 ? 's' : ''}`, + `Photography album${album.location ? ` from ${album.location}` : ''} with ${album._count.media} photo${album._count.media !== 1 ? 's' : ''}`, content: album.description ? `

${escapeXML(album.description)}

` : '', link: `${event.url.origin}/photos/${album.slug}`, guid: `${event.url.origin}/photos/${album.slug}`, pubDate: album.createdAt, updatedDate: album.updatedAt, - photoCount: album._count.photos, - coverPhoto: album.photos[0], + photoCount: album._count.media, + coverPhoto: album.media[0]?.media, location: album.location, date: album.date })) @@ -209,9 +219,9 @@ ${item.updatedDate ? `${new Date(item.updatedDate).toISOString()}< ${ item.type === 'album' && item.coverPhoto ? ` - - -` + + +` : '' } ${item.location ? `${escapeXML(item.location)}` : ''}