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.

34 lines
1.0 KiB

  1. const sql = require('../utils/sql');
  2. module.exports=
  3. {
  4. /**Renders the popular posts sidebar.
  5. *
  6. * @param res
  7. * @returns {*|Promise}
  8. */
  9. main: function(res)
  10. {
  11. return new Promise(function(resolve, reject)
  12. {
  13. res.write("<div class=\"w3-card w3-margin\">");
  14. res.write("<div class=\"w3-container w3-padding\">" +
  15. "<h4>Popular Posts</h4></div>");
  16. res.write("<div class=\"w3-sidebar w3-bar-block\">");
  17. sql.getPopularPosts().then(function(posts)
  18. {
  19. posts.forEach(function(cat)
  20. {
  21. console.log(cat);
  22. res.write("<a class=\"w3-bar-item w3-button\" href='"
  23. + url + "'>" + p.name + "<br></a>");
  24. });
  25. res.write("</div></div>");
  26. resolve();
  27. });
  28. });
  29. }
  30. };