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.

59 lines
1.4 KiB

  1. const utils = require('../utils/utils.js');
  2. var Promise = require('promise');
  3. module.exports=
  4. {
  5. /**
  6. * renderPost() displays a single blog post in it's entirety
  7. *
  8. * @param res result sent to user
  9. * @param post sql data about the blog post
  10. * @return {*|Promise}
  11. */
  12. renderPost: function(res, post)
  13. {
  14. return new Promise(function (resolve, reject)
  15. {
  16. res.write("<div class=\"w3-card-4 w3-margin w3-white\">");
  17. //image
  18. res.write("<div class=\"w3-container\">");
  19. //title
  20. res.write("<h3><b>" + post.name + "</b></h3>");
  21. //date
  22. res.write("<h5><span class=\"w3-opacity\">" + post.date + "</span></h5>");
  23. res.write("</div>");
  24. res.write("<div class=\"w3-container\">");
  25. //include page content
  26. utils.include(res, "../entries/" + post.url).then(function (value) {
  27. res.write("</div></div>");
  28. resolve();
  29. });
  30. });
  31. }
  32. };
  33. /*
  34. <div class="w3-card-4 w3-margin w3-white">
  35. <img src="/w3images/woods.jpg" alt="Nature" style="width:100%">
  36. <div class="w3-container">
  37. <h3><b>TITLE HEADING</b></h3>
  38. <h5>Title description, <span class="w3-opacity">Date</span></h5>
  39. </div>
  40. <div class="w3-container">
  41. content
  42. </div>
  43. </div>
  44. */