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.
 
 

42 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)
{
console.log(requestURL);
return new Promise(function(resolve, reject)
{
var page = request.query.page;
const category = requestURL.split("/").join("");
templateContext["title"] = category;
sql.getPostsFromCategory(category).then(function(posts)
{
templateContext["categoryID"] = posts[0].category_id;
Promise.all([blogBodyRenderer.renderBatchOfPosts(requestURL, posts, page, 5, templateContext),
require('./renderNextBar').main("/category" + request.url, page, 5, posts.length, templateContext)]).then(function()
{
resolve();
});
}).catch(function()
{
delete templateContext["posts"];
reject();
});
});
}
};