Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
1.4 KiB

/** DB query */
const sql = require('../utils/sql');
/** Object used to render blog post previews */
const blogBodyRenderer = require('./renderBlogPost');
module.exports=
{
/**
* Calls blog and sidebar modules to render blog contents in order
*
* @param requestURL
* @param request
* @returns {Promise}
*/
main: function(requestURL, request, templateContext)
{
return new Promise(function(resolve, reject)
{
var page = request.query.page;
const splitURL = requestURL.split("/");
if(splitURL.length >= 3)
{
sql.getPostsFromCategory(splitURL[2]).then(function(posts)
{
blogBodyRenderer.renderBatchOfPosts(requestURL, posts, page, 5, templateContext).then(function()
{
console.log("good");
resolve();
});
}).catch(function()
{
delete templateContext["posts"];
resolve();
});
}
else
{
//page is not found but, posts list will be empty
// so 404 will display
resolve();
}
});
}
};