File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ import rss from '@astrojs/rss'
2+ import type { APIContext } from 'astro'
3+ import { getCollection } from 'astro:content'
4+
5+ import siteConfig from '@/configs/site'
6+
7+ const { title, description } = siteConfig
8+
9+ export const get = async ( { site } : APIContext ) => {
10+ if ( site === undefined || site . toString ( ) . length === 0 ) {
11+ return {
12+ body : ''
13+ }
14+ }
15+
16+ const allPosts = await getCollection ( 'leetcode-solutions' )
17+
18+ return rss ( {
19+ title,
20+ description,
21+ site : site . toString ( ) ,
22+ items : allPosts . map ( ( post ) => ( {
23+ title : post . data . title ,
24+ description : `LeetCode Problem #${ post . data . title } ` ,
25+ pubDate : new Date ( post . data . pubDate ) ,
26+ link : `/${ post . slug } ` ,
27+ } ) ) ,
28+ customData : '<language>en-US</language>' ,
29+ } )
30+ }
You can’t perform that action at this time.
0 commit comments