fp/services/next/app/lib/rss.ts

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-01-20 16:16:14 +00:00
import { authorName, authorEmail, siteUrl, title, description, siteImage, favicon, authorLink } from './constants'
import { Feed } from "feed";
2024-07-10 22:11:18 +00:00
import { getVods, getUrl, IVod } from '@/app/lib/vods'
import { ITagVodRelation } from '@/app/lib/tag-vod-relations';
2024-01-20 16:16:14 +00:00
export async function generateFeeds() {
const feedOptions = {
id: siteUrl,
title: title,
description: description,
link: siteUrl,
language: 'en',
image: siteImage,
favicon: favicon,
copyright: '',
generator: ' ',
feedLinks: {
json: `${siteUrl}/feed/feed.json`,
atom: `${siteUrl}/feed/feed.xml`
},
author: {
name: authorName,
email: authorEmail,
link: authorLink
}
};
const feed = new Feed(feedOptions);
const vods = await getVods()
vods.data.map((vod: IVod) => {
feed.addItem({
2025-01-11 03:10:04 +00:00
title: vod.title || vod.announceTitle,
description: vod.title, // @todo vod.spoiler or vod.note could go here
content: vod.tagVodRelations.data.map((tvr: ITagVodRelation) => tvr.attributes.tag.name).join(' '),
link: getUrl(vod, vod.vtuber.slug, vod.date2),
date: new Date(vod.date2),
image: vod.vtuber.image
2024-01-20 16:16:14 +00:00
})
})
return {
atom1: feed.atom1(),
rss2: feed.rss2(),
json1: feed.json1()
}
}