From b21496ae3794ebc7e7758e65c3b05463106b24b7 Mon Sep 17 00:00:00 2001 From: Daniel Norman Date: Mon, 23 Sep 2019 12:16:53 +0200 Subject: [PATCH] Select the first leading element for draft titles Some medium exported drafts have multiple elements with the `graf--leading` class. When multiples exists the resulting `titleForSlug` can be potentially very long and cause the image fetching to fail due to too long file names. --- lib/converter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/converter.js b/lib/converter.js index 665e29d..73ca617 100644 --- a/lib/converter.js +++ b/lib/converter.js @@ -118,7 +118,7 @@ async function gatherPostData(content, options, filePath) { else { // construct a canonical link var canonicalLink = $('footer > p > a').attr('href'); - var blogTitle = $(".graf--leading").text() + var blogTitle = $(".graf--leading").first().text() var titleForSlug = convertToSlug(blogTitle) }