include enclosure only if thumbnail is present

This commit is contained in:
teddit 2021-01-01 19:56:19 +01:00
parent e49d6e4917
commit 2dbfffb055
1 changed files with 12 additions and 8 deletions

View File

@ -50,13 +50,17 @@ module.exports = function() {
if(is_self_link) if(is_self_link)
link.url = link.permalink link.url = link.permalink
let thumb_mime = '' let enclosure = ''
let ext = thumbnail.split('.').pop() if(thumbnail != '') {
if(ext === 'png') let mime = ''
thumb_mime = 'image/png' let ext = thumbnail.split('.').pop()
else if(ext === 'png')
thumb_mime = 'image/jpeg' mime = 'image/png'
else
mime = 'image/jpeg'
enclosure = `<enclosure length="0" type="${mime}" url="${thumbnail}" />`
}
let append_desc_html = `<br/><a href="${link.url}">[link]</a> <a href="${link.permalink}">[comments]</a>` let append_desc_html = `<br/><a href="${link.url}">[link]</a> <a href="${link.permalink}">[comments]</a>`
@ -68,7 +72,7 @@ module.exports = function() {
<domain>${link.domain}</domain> <domain>${link.domain}</domain>
<id>${link.id}</id> <id>${link.id}</id>
<thumbnail>${thumbnail}</thumbnail> <thumbnail>${thumbnail}</thumbnail>
<enclosure length="0" type="${thumb_mime}" url="${thumbnail}" /> ${enclosure}
<link>${link.permalink}</link> <link>${link.permalink}</link>
<url>${link.url}</url> <url>${link.url}</url>
<description><![CDATA[${unescape(link.selftext_html)}${append_desc_html}]]></description> <description><![CDATA[${unescape(link.selftext_html)}${append_desc_html}]]></description>