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.

42 lines
1.3 KiB

  1. const Promise = require('promise');
  2. const sql = require('../utils/sql');
  3. module.exports=
  4. {
  5. /** Renders the the recent post sidebar.
  6. *
  7. * @returns {*|Promise}
  8. */
  9. main: function()
  10. {
  11. return new Promise(function(resolve, reject)
  12. {
  13. console.log("recent page");
  14. var content = "<div class=\"container\">";
  15. content +="<div class=\"list-group\">";
  16. content +=" <a href=\"#\" class=\"list-group-item list-group-item-action flex-column align-items-start active\">\n" +
  17. " <h5 class=\"mb-1\">Recent Posts</h5>\n" +
  18. " </a>";
  19. sql.getRecentPosts().then(function(posts)
  20. {
  21. posts.forEach(function(p)
  22. {
  23. var url = '/' + p.category + '/' + p.url;
  24. content += "<a class=\"list-group-item\" href='"
  25. + url + "'>" + p.name + "<br></a>";
  26. });
  27. content +="</div></div>";
  28. resolve(content);
  29. }).catch(function(error)
  30. {
  31. reject(error);
  32. })
  33. });
  34. }
  35. };