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
1.0 KiB

  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. templateContext["categoryID"] = 0;
  15. return new Promise(function(resolve, reject)
  16. {
  17. sql.getAllPosts().then(function(posts)
  18. {
  19. Promise.all([blogPostRenderer.renderBatchOfPosts(requestURL, posts, page, 5, templateContext),
  20. require('./renderNextBar').main(requestURL, page, 5, posts.length, templateContext)]).then(function()
  21. {
  22. resolve();
  23. });
  24. }).catch(function(error)
  25. {
  26. reject(error);
  27. })
  28. });
  29. }
  30. };