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.

31 lines
1009 B

  1. const sql = require('../utils/sql');
  2. const blogPostRenderer = require('./renderBlogPost.js');
  3. module.exports=
  4. {
  5. /**
  6. * Renders the previews of recent blog blog and the side bar
  7. *
  8. * @param res
  9. * @param fileName request url
  10. */
  11. main: function(requestURL, request, templateContext)
  12. {
  13. var page = request.query.page;
  14. return new Promise(function(resolve, reject)
  15. {
  16. sql.getAllPosts().then(function(posts)
  17. {
  18. Promise.all([blogPostRenderer.renderBatchOfPosts(requestURL, posts, page, 5, templateContext),
  19. require('./renderNextBar').main(requestURL, page, 5, posts.length, templateContext)]).then(function()
  20. {
  21. resolve();
  22. });
  23. }).catch(function(error)
  24. {
  25. reject(error);
  26. })
  27. });
  28. }
  29. };