Skip to content

Commit

Permalink
add title for html blog
Browse files Browse the repository at this point in the history
  • Loading branch information
madneal committed Feb 12, 2018
1 parent 97d64fa commit 4cae8cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ function exportMedium() {
const parser = new DOMParser()
const doc = parser.parseFromString(res, 'text/html')
var blog = doc.querySelector('.article-post-wrapper')
title = doc.querySelector('.blog-details h2')
title = doc.querySelector('.full-bleed-data h2').innerText
const turndownService = new TurndownService()
markdownText = turndownService.turndown(blog)
if (title != null) {
markdownText = '# ' + title + '\n' + turndownService.turndown(blog)
} else {
markdownText = turndownService.turndown(blog)
}
} else {
const story = parseJsonToMarkdown(res)
markdownText = story.markdown.join('')
Expand All @@ -82,6 +86,7 @@ function exportMedium() {
})
.catch(function (err) {
console.error(err)
cancelLoad()
})
})
}
Expand Down

0 comments on commit 4cae8cd

Please sign in to comment.