import { escape } from '@/lib/utils/htmlEscaper'; import siteMetadata from '@/data/siteMetadata'; import { PostFrontMatter } from 'types/PostFrontMatter'; const generateRssItem = (post: PostFrontMatter) => ` ${siteMetadata.siteUrl}/blog/${post.slug} ${escape(post.title)} ${siteMetadata.siteUrl}/blog/${post.slug} ${post.summary && `${escape(post.summary)}`} ${new Date(post.date).toUTCString()} ${siteMetadata.email} (${siteMetadata.author}) ${post.tags && post.tags.map((t) => `${t}`).join('')} `; const generateRss = (posts: PostFrontMatter[], page = 'feed.xml') => ` ${escape(siteMetadata.title)} ${siteMetadata.siteUrl}/blog ${escape(siteMetadata.description)} ${siteMetadata.language} ${siteMetadata.email} (${ siteMetadata.author }) ${siteMetadata.email} (${siteMetadata.author}) ${new Date(posts[0].date).toUTCString()} ${posts.map(generateRssItem).join('')} `; export default generateRss;