Skip to content

Commit

Permalink
Fix - fetch title inclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
am1t committed Aug 8, 2018
1 parent b6f95a3 commit 714de20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,17 @@ const getTitle = function(doc) {
return Promise.resolve("\n");
}

request(url, function (error, response, body) {
if (!error && response.statusCode === 200) {
var $ = cheerio.load(body);
var title = $("head > title").text().trim();
return Promise.resolve(title_pre + " : " + title + "\n");
} else {
console.log('Failed to load the title for ', url);
return Promise.resolve(title_pre + " : a post\n");
}
return new Promise((resolve, reject) => {
request(url, function (error, response, body) {
if (!error && response.statusCode === 200) {
var $ = cheerio.load(body);
var title = $("head > title").text().trim();
resolve(title_pre + " : " + title + "\n");
} else {
console.log('Failed to load the title for ', url);
resolve(title_pre + " : a post\n");
}
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = {
post_path: env['POST_PATH'],
micro_post_path: env['MICRO_POST_PATH'] !== undefined ? env['MICRO_POST_PATH'] : env['POST_PATH'],
site_url: env['SITE_URL'],
set_date: JSON.parse(env['SET_DATE'])
set_date: JSON.parse(env['SET_DATE'] ? env['SET_DATE'] : false)
}

module.exports = config;

0 comments on commit 714de20

Please sign in to comment.