Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix parsing gist embed with a caption
- Loading branch information
1 parent
e4f1255
commit 1b4b42d
Showing
16 changed files
with
580 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path') | ||
const inquirer = require('inquirer') | ||
const ora = require('ora') | ||
const { | ||
getMarkdownFromOnlinePost, | ||
} = require('../lib/import-article-from-medium') | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(` ------------------------- | ||
Hello there! | ||
Let's import one of your Medium article here. | ||
`) | ||
|
||
let spinner | ||
|
||
inquirer | ||
.prompt([ | ||
{ | ||
name: 'canonicalLink', | ||
message: 'URL of the Medium article', | ||
}, | ||
]) | ||
.then(({ canonicalLink }) => { | ||
canonicalLink = canonicalLink.trim() | ||
if (!canonicalLink) { | ||
throw new Error(` | ||
We do need the URL to import the article...`) | ||
} | ||
spinner = ora('Parsing Medium article').start() | ||
|
||
return getMarkdownFromOnlinePost( | ||
path.join(process.cwd(), './content'), | ||
canonicalLink | ||
) | ||
}) | ||
.then(slug => { | ||
if (!slug) { | ||
throw new Error( | ||
'Looks like the URL points to a draft or a response to an article. We cannot import that.' | ||
) | ||
} | ||
// eslint-disable-next-line no-console | ||
console.log(` | ||
------------------------- | ||
Your article is ready to go! 🙌 | ||
You can find it here: ${path.join(process.cwd(), './content', slug)} | ||
Happy blogging! | ||
... | ||
`) | ||
}) | ||
.then(() => process.exit(0)) | ||
.catch(err => { | ||
if (spinner) { | ||
spinner.fail() | ||
} | ||
// eslint-disable-next-line no-console | ||
console.log() | ||
// eslint-disable-next-line no-console | ||
console.error(err) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.