@@ -35,7 +35,7 @@ export async function generateRssFeed(type: 'rss' | 'atom' | 'json' = 'rss') {
3535 allPosts . forEach ( ( post ) => {
3636 const url = `https://blog.trialanderror.org/${ post . slug } ?utm_source=rss&utm_medium=rss&utm_campaign=rss`
3737
38- const image = post . image ?. formats ?. medium ?. url ?? post . image . url
38+ const image = post . image ?. formats ?. thumbnail ?? post . image
3939 const author =
4040 [ ...( post . team_members ?? [ ] ) , ...( post . blog_authors ?? [ ] ) ]
4141 . map ( ( member ) => {
@@ -53,36 +53,46 @@ export async function generateRssFeed(type: 'rss' | 'atom' | 'json' = 'rss') {
5353 date : new Date ( post . publishedAt ?? post . publishDate ?? Date . now ( ) ) ,
5454 link : url ,
5555 description : post . excerpt ,
56- guid : post . slug ,
56+ guid : url ,
5757 content : url ,
58- // image: post.image?.formats?.thumbnail?.url ?? post.image.url,
58+ published : new Date ( post . publishedAt ?? post . publishDate ?? Date . now ( ) ) ,
59+
5960 category : [
6061 {
61- term : post . category ?. title ,
62+ name : post . category ?. title ,
6263 } ,
6364 ...( post . blog_tags ?. map ( ( tag ) => ( {
64- term : tag . title ,
65+ name : tag . title ,
6566 } ) ) ?? [ ] ) ,
6667 ] ,
67- // image: 'https://google.com',
6868 ...( image
6969 ? {
7070 image,
7171 }
7272 : { } ) ,
7373 ...( author . length ? { author } : { } ) ,
74+ ...( image
75+ ? {
76+ extensions : [
77+ {
78+ name : `media:thumbnail width="${ image . width } " height="${ image . height } " url="${ image . url } "` ,
79+ } ,
80+ ] ,
81+ }
82+ : { } ) ,
7483 } )
7584 } )
85+ feed . addExtension ( { } )
7686
7787 if ( type === 'rss' ) {
7888 return feed . rss2 ( )
7989 }
8090
81- if ( type === 'atom' ) {
82- return feed . atom1 ( )
83- }
91+ // if (type === 'atom') {
92+ // return feed.atom1()
93+ // }
8494
85- if ( type === 'json' ) {
86- return feed . json1 ( )
87- }
95+ // if (type === 'json') {
96+ // return feed.json1()
97+ // }
8898}
0 commit comments