Skip to content

Instantly share code, notes, and snippets.

@renakim
Created February 10, 2022 00:28
Show Gist options
  • Save renakim/d67b78cd94ce9416d3a5bc93c0d67687 to your computer and use it in GitHub Desktop.
Save renakim/d67b78cd94ce9416d3a5bc93c0d67687 to your computer and use it in GitHub Desktop.
medium-to-markdown file save
const mediumToMarkdown = require("medium-to-markdown");
const fs = require("fs");
const link = <medium post url>
// Enter url here
mediumToMarkdown.convertFromUrl(link).then(function(markdown) {
// console.log(markdown); //=> Markdown content of medium post
// medium.com/ 이후의 string 값을 파일명으로 사용
filename = `${link.split("/").slice(-1)[0]}.md`;
fs.writeFile(filename, markdown, (err) => {
if (err === null) {
console.log(`File saved: ${filename}`);
} else {
console.log(err);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment