| 1 | import { Feed } from "feed"; |
| 2 | import { getPhotos } from "$lib/feed"; |
| 3 | import type { RequestHandler } from "./$types"; |
| 4 | |
| 5 | export const GET: RequestHandler = async ({ platform }) => { |
| 6 | const feed = new Feed({ |
| 7 | title: "steve.photo", |
| 8 | description: "Personal photography portolio of Steve Simkins", |
| 9 | id: "https://steve.photo", |
| 10 | link: "https://steve.photo/", |
| 11 | language: "en", |
| 12 | favicon: "https://steve.photo/favicon.ico", |
| 13 | copyright: `Copyright ${new Date().getFullYear().toString()}, Steve Simkins`, |
| 14 | feedLinks: { |
| 15 | rss: "https://steve.photo/rss.xml", |
| 16 | }, |
| 17 | author: { |
| 18 | name: "Steve Simkins", |
| 19 | email: "contact@stevedylan.dev", |
| 20 | link: "https://stevedylan.dev", |
| 21 | }, |
| 22 | ttl: 60, |
| 23 | }); |
| 24 | |
| 25 | const photos = await getPhotos(platform); |
| 26 | |
| 27 | for (const photo of photos) { |
| 28 | feed.addItem({ |
| 29 | title: photo.title, |
| 30 | id: `https://steve.photo/photo/${photo.slug}`, |
| 31 | link: `https://steve.photo/photo/${photo.slug}`, |
| 32 | date: new Date(photo.date), |
| 33 | image: photo.image, |
| 34 | author: [ |
| 35 | { |
| 36 | name: "Steve Simkins", |
| 37 | email: "contact@stevedylan.dev", |
| 38 | link: "https://stevedylan.dev", |
| 39 | }, |
| 40 | ], |
| 41 | content: `<img src="${photo.image}" alt="${photo.title}" /><p>Camera: ${photo.camera} | Lens: ${photo.lens} | ${photo.aperture} | ${photo.exposure} | ISO ${photo.iso}</p>`, |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | return new Response(feed.rss2(), { |
| 46 | headers: { |
| 47 | "Content-Type": "application/xml; charset=utf-8", |
| 48 | }, |
| 49 | }); |
| 50 | }; |