Implement basic fetchFromMedium command
This commit is contained in:
parent
bafc64fb5b
commit
ccce3dc172
2 changed files with 9 additions and 3 deletions
|
@ -1,11 +1,13 @@
|
||||||
const r2 = require('r2')
|
const r2 = require('r2')
|
||||||
|
const getPost = require('mediumexporter').getPost
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function [fetchFromMedium]
|
* function [fetchFromMedium]
|
||||||
* @returns [string] status
|
* @returns [string] status
|
||||||
*/
|
*/
|
||||||
const fetchFromMedium = (mediumUrl) => {
|
const fetchFromMedium = async (mediumUrl) => {
|
||||||
console.info('Fetching: ' + mediumUrl);
|
console.debug('Fetching: ' + mediumUrl);
|
||||||
|
return await getPost(mediumUrl, { returnObject: true })
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
6
index.js
6
index.js
|
@ -17,7 +17,11 @@ program.command('fetch-medium <post_url>')
|
||||||
.alias('fetch')
|
.alias('fetch')
|
||||||
.description('fetch a Medium post')
|
.description('fetch a Medium post')
|
||||||
.action((post_url) => {
|
.action((post_url) => {
|
||||||
fetchFromMedium(post_url);
|
fetchFromMedium(post_url)
|
||||||
|
.then((post) => {
|
||||||
|
console.info(`"${post.title}" fetched successfully`)
|
||||||
|
console.debug(post)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('push-ghost <file>')
|
program.command('push-ghost <file>')
|
||||||
|
|
Loading…
Reference in a new issue