From b04072e5fc0ae176343ce995fa6fe3468d3a33c0 Mon Sep 17 00:00:00 2001 From: Logan Rockmore Date: Mon, 23 Dec 2019 02:17:02 -0700 Subject: [PATCH] feat: Clean up the Dribbble posts a bit more. (#3622) * Make sure to include the content of multiple media shots. * Remove extra content in the media. Co-authored-by: Logan Rockmore --- lib/routes/dribbble/utils.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/routes/dribbble/utils.js b/lib/routes/dribbble/utils.js index 069995907b..d7c40e1d17 100644 --- a/lib/routes/dribbble/utils.js +++ b/lib/routes/dribbble/utils.js @@ -6,7 +6,17 @@ async function load(link) { const response = await got.get(link); const $ = cheerio.load(response.data); - const shotMedia = $('.media-shot').html() || $('.main-shot').html() || ''; + const shotMedia = $('.media-shot,.main-shot') // join multiple shots together + .toArray() + .map((element) => { + const object = $(element); + + // remove the content that we don't want to show + object.find('span.cropped-indicator').remove(); + + return object.html(); + }) + .join(''); const shotDescription = $('.shot-desc').html() || ''; const shotViews = $('.shot-views').text() || '0 views';