Skip to content

Commit

Permalink
Add captions to reddit gallery expandos (#5461)
Browse files Browse the repository at this point in the history
  • Loading branch information
brookst authored Apr 11, 2023
1 parent 6122e66 commit c43f629
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/modules/hosts/redditgallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default new Host('redditgallery', {
async handleLink(href, [, id]) {
const {
media_metadata = {},
selftext_html,
gallery_data: {
items = [],
} = {},
Expand All @@ -24,6 +25,6 @@ export default new Host('redditgallery', {
return type === 'IMAGE' ? [{ type, caption, src: `https://i.redd.it/${media_id}.${m.substr(6)}` }] : undefined;
});
if (!pieces.length) throw new Error('Gallery has no valid pieces.');
return { type: 'GALLERY', src: pieces };
return { type: 'GALLERY', src: pieces, caption: selftext_html && selftext_html.replace(/<\/?p>/g, '') };
},
});

0 comments on commit c43f629

Please sign in to comment.