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.
 
 

46 lines
1.2 KiB

const sql = require('../utils/sql');
const batchPreview = require('../posts/renderBatchOfPreviewes');
/**Renders each recent post for the homepage of the website
*
* @param result
* @returns {*|Promise}
*/
var renderRecentPosts = function(baseURL, page)
{
return new Promise(function(resolve, reject)
{
sql.getRecentPostSQL().then(function(posts)
{
resolve(batchPreview.main(baseURL, posts, page, 5));
}).catch(function(error)
{
reject(error);
})
});
};
module.exports=
{
/**
* Renders the previews of recent blog posts and the side bar
*
* @param res
* @param fileName request url
*/
main: function(requestURL, request)
{
var page = request.query.page;
return new Promise(function(resolve, reject)
{
Promise.all([renderRecentPosts(requestURL, page), require("../sidebar/sidebar.js").main()]).then(function(content)
{
resolve(content.join(''));
}).catch(function(error)
{
reject(error);
});
})
}
};