Skip to content

Commit b8b27fd

Browse files
committed
fix: add correct xml namespace to enable media elements
1 parent c8cf526 commit b8b27fd

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

apps/next-blog/src/utils/generateRSSFeed.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ export async function generateRssFeed(type: 'rss' | 'atom' | 'json' = 'rss') {
2222
favicon: `${site_url}/favicon.ico`,
2323
copyright: `CC-BY 4.0 ${new Date().getFullYear()}, Center of Trial and Error`,
2424
generator: 'Feed for Node.js',
25+
2526
feedLinks: {
2627
rss2: `/rss.xml`,
27-
// // other feed formats
28-
// json: `/rss.json`,
29-
// atom: `/rss.xml`,
3028
},
3129
}
3230

@@ -82,17 +80,13 @@ export async function generateRssFeed(type: 'rss' | 'atom' | 'json' = 'rss') {
8280
: {}),
8381
})
8482
})
85-
feed.addExtension({})
8683

87-
if (type === 'rss') {
88-
return feed.rss2()
89-
}
84+
const feedString = feed.rss2()
9085

91-
// if (type === 'atom') {
92-
// return feed.atom1()
93-
// }
86+
const feedstringWithCorrectXml = feedString.replace(
87+
/(<rss.*)>/,
88+
'$1 xmlns:media="http://search.yahoo.com/mrss/"',
89+
)
9490

95-
// if (type === 'json') {
96-
// return feed.json1()
97-
// }
91+
return feedstringWithCorrectXml
9892
}

0 commit comments

Comments
 (0)