diff --git a/app/feed.json/route.ts b/app/feed.json/route.ts index 0c4eb1ea..0cd6fe67 100644 --- a/app/feed.json/route.ts +++ b/app/feed.json/route.ts @@ -11,7 +11,7 @@ export async function GET() { const photos = await getPhotosCached({ limit: FEED_PHOTO_REQUEST_LIMIT, sortBy: 'createdAt', - }); + }).catch(() => []); return Response.json(formatFeedJson(photos)); } else { return new Response('Feeds disabled', { status: 404 }); diff --git a/app/rss.xml/route.ts b/app/rss.xml/route.ts index fb2e862a..f9ea9ce2 100644 --- a/app/rss.xml/route.ts +++ b/app/rss.xml/route.ts @@ -1,7 +1,7 @@ import { getPhotosCached } from '@/photo/cache'; import { SITE_FEEDS_ENABLED } from '@/app/config'; import { FEED_PHOTO_REQUEST_LIMIT } from '@/feed'; -import { formatFeedRss } from '@/feed/rss'; +import { formatFeedRssXml } from '@/feed/rss'; // Cache for 24 hours export const revalidate = 86_400; @@ -11,10 +11,9 @@ export async function GET() { const photos = await getPhotosCached({ limit: FEED_PHOTO_REQUEST_LIMIT, sortBy: 'createdAt', - }); - + }).catch(() => []); return new Response( - formatFeedRss(photos), + formatFeedRssXml(photos), { headers: { 'Content-Type': 'text/xml' } }, ); } else { diff --git a/app/sitemap.ts b/app/sitemap.ts index a6d7e5ba..363d5bb2 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -34,8 +34,15 @@ export default async function sitemap(): Promise { }, photos, ] = await Promise.all([ - getDataForCategoriesCached(), - getPhotoIdsAndUpdatedAt(), + getDataForCategoriesCached().catch(() => ({ + cameras: [], + lenses: [], + tags: [], + recipes: [], + films: [], + focalLengths: [], + })), + getPhotoIdsAndUpdatedAt().catch(() => []), ]); const lastModifiedSite = [ diff --git a/src/feed/rss.ts b/src/feed/rss.ts index 56e53e42..1fb975fe 100644 --- a/src/feed/rss.ts +++ b/src/feed/rss.ts @@ -57,7 +57,7 @@ const feedPhotoToXml = (photo: FeedPhotoRss): string => { `; }; -export const formatFeedRss = (photos: Photo[]) => +export const formatFeedRssXml = (photos: Photo[]) => `