Skip to content

Commit

Permalink
rss: twitter user: add images
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed May 18, 2018
1 parent f26f8ee commit a565235
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions routes/twitter/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ module.exports = async (ctx) => {
title: `${data[0].user.name} 的 Twitter`,
link: `https://twitter.com/${id}/`,
description: data[0].user.description,
item: data.map((item) => ({
title: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.text.length > 30 ? item.text.slice(0, 30) + '...' : item.text}`,
description: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.text}`,
pubDate: new Date(item.created_at).toUTCString(),
link: `https://twitter.com/${id}/status/${item.id_str}`,
})),
item: data.map((item) => {
let img = '';
item.extended_entities &&
item.extended_entities.media.forEach((item) => {
img += `<br>${item.type === 'video' ? 'Video: ' : ''}<img referrerpolicy="no-referrer" src="${item.media_url_https}">`;
});
return {
title: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.text.length > 30 ? item.text.slice(0, 30) + '...' : item.text}`,
description: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.text}${img}`,
pubDate: new Date(item.created_at).toUTCString(),
link: `https://twitter.com/${id}/status/${item.id_str}`,
};
}),
};
};

0 comments on commit a565235

Please sign in to comment.