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.

40 lines
1.2 KiB

  1. /** DB query */
  2. const sql = require('../utils/sql');
  3. /** Object used to render blog post previews */
  4. const blogBodyRenderer = require('./renderBlogPost');
  5. module.exports=
  6. {
  7. /**
  8. * Calls blog and sidebar modules to render blog contents in order
  9. *
  10. * @param requestURL
  11. * @param request
  12. * @returns {Promise}
  13. */
  14. main: function(requestURL, request, templateContext)
  15. {
  16. console.log(requestURL);
  17. return new Promise(function(resolve, reject)
  18. {
  19. var page = request.query.page;
  20. const category = requestURL.split("/").join("");
  21. sql.getPostsFromCategory(category).then(function(posts)
  22. {
  23. Promise.all([blogBodyRenderer.renderBatchOfPosts(requestURL, posts, page, 5, templateContext),
  24. require('./renderNextBar').main(requestURL, page, 5, posts.length, templateContext)]).then(function()
  25. {
  26. resolve();
  27. });
  28. }).catch(function()
  29. {
  30. delete templateContext["posts"];
  31. reject();
  32. });
  33. });
  34. }
  35. };