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.
 
 

32 lines
1009 B

const sql = require('../utils/sql');
const blogPostRenderer = require('./renderBlogPost.js');
module.exports=
{
/**
* Renders the previews of recent blog blog and the side bar
*
* @param res
* @param fileName request url
*/
main: function(requestURL, request, templateContext)
{
var page = request.query.page;
return new Promise(function(resolve, reject)
{
sql.getAllPosts().then(function(posts)
{
Promise.all([blogPostRenderer.renderBatchOfPosts(requestURL, posts, page, 5, templateContext),
require('./renderNextBar').main(requestURL, page, 5, posts.length, templateContext)]).then(function()
{
resolve();
});
}).catch(function(error)
{
reject(error);
})
});
}
};