diff --git a/src/curate/submissions.js b/src/curate/submissions.js index 83b322b..0455c61 100644 --- a/src/curate/submissions.js +++ b/src/curate/submissions.js @@ -9,10 +9,14 @@ function curateSubmissions(submissions) { return submissions.reduce((acc, submission, index) => { const host = dissectLink(submission.url); - if(config.fetch.avoidDuplicates && processed.has(host.id)) { - console.log('\x1b[33m%s\x1b[0m', `Ignoring cross-post or repost '${submission.title}' - ${submission.url}`); + if(host) { + if(config.fetch.avoidDuplicates && processed.has(host.id)) { + console.log('\x1b[33m%s\x1b[0m', `Ignoring cross-post or repost '${submission.title}' - ${submission.url}`); - return acc; + return acc; + } + + processed.add(host.id); } const curatedSubmission = { @@ -28,8 +32,6 @@ function curateSubmissions(submissions) { host }; - processed.add(host.id); - return acc.concat(curatedSubmission); }, []); }; diff --git a/src/fetch/content.js b/src/fetch/content.js index c110533..29c8e56 100644 --- a/src/fetch/content.js +++ b/src/fetch/content.js @@ -42,7 +42,7 @@ module.exports = function(posts, user) { }).then(() => { return save(filepath, item.stream); }).then(() => { - const interpolatedMeta = Object.entries(config.library.meta).reduce((acc, [key, value]) => { + const meta = Object.entries(config.library.meta).reduce((acc, [key, value]) => { const interpolatedValue = interpolate(value, user, post, item); if(interpolatedValue) { @@ -52,10 +52,8 @@ module.exports = function(posts, user) { return acc; }, {}); - if(Object.keys(interpolatedMeta).length > 0) { - return saveMeta(filepath, { - comment: item.description - }, ep); + if(Object.keys(meta).length > 0) { + return saveMeta(filepath, meta, ep); } }); }));