diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-25 18:14:08 +0100 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-25 18:14:48 +0100 |
| commit | 6972d357c69495b6e1beee75e8441815bd3d5c72 (patch) | |
| tree | 5d110b839b6b3fa51ed5f3c8df7877da5669536f /src/pages | |
| parent | f3574b604b35d2e7c027b79c9c05c4b81d753390 (diff) | |
Adds Lallans to RSS feed
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/[locale]/rss.xml.ts | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/pages/[locale]/rss.xml.ts b/src/pages/[locale]/rss.xml.ts index be2cab6..0feb866 100644 --- a/src/pages/[locale]/rss.xml.ts +++ b/src/pages/[locale]/rss.xml.ts @@ -6,21 +6,26 @@ import getLocaleFromPath from '$lib/getLocaleFromPath'; import type { APIContext } from 'astro'; import translate from '$i18n/translate'; import tFeed from '$i18n/translations/pages/rss.xml'; +import type LallansIssue from '$types/LallansIssue'; +import type Locale from '$types/Locale'; +import { getAllLallansIssues } from '$data/lallans'; export async function get(context: APIContext) { const locale = getLocaleFromPath(context.url.pathname); const t = translate(locale); - const news = (await getCollection('news')).filter((item) => isNewsItemInLocale(item, locale)); const site = context.site; if (!site) { throw new Error('No site provided in Astro configuration'); } + const news = (await getCollection('news')).filter((item) => isNewsItemInLocale(item, locale)); + const lallans = await getAllLallansIssues(); + return rss({ title: t(tFeed, { key: 'title' }), description: t(tFeed, { key: 'description' }), site, - items: news.map(newsItemToRssFeedItem), + items: [...news.map(newsItemToRssFeedItem), ...lallans.map(lallansIssueToRssFeedItem(locale))], customData: `<language>${locale}</language>`, }); } @@ -39,6 +44,17 @@ function newsItemToRssFeedItem(item: CollectionEntry<'news'>): RSSFeedItem { }; } +function lallansIssueToRssFeedItem(locale: Locale) { + return function (issue: LallansIssue): RSSFeedItem { + return { + link: `/${locale}/furthsettins/lallans/${issue.issueNumber}`, + title: issue.issueName, + description: issue.description[locale], + pubDate: new Date(issue.uploadDate), + }; + }; +} + export async function getStaticPaths() { return localeStaticPaths; } |
