From 41ac3e767394d47bf6c07ec35d9143a989d37668 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sun, 24 May 2020 20:00:08 -0400 Subject: [PATCH] Moved button html gen to template and (closes #88) --- blog/renderBlogPost.js | 21 +++++++--------- templates/blog/blogMain.html | 46 +++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/blog/renderBlogPost.js b/blog/renderBlogPost.js index 42d62bf..420d81f 100644 --- a/blog/renderBlogPost.js +++ b/blog/renderBlogPost.js @@ -46,7 +46,7 @@ module.exports= generateBlogPostHeader: function(post) { if(post.picture_url !== "n/a") - post. hasPicture = true; + post.hasPicture = true; post.published = post.published.toDateString(); return; @@ -69,8 +69,9 @@ module.exports= { module.exports.generateBlogPostComponent(category[0].url, post.url, blocks).then(function(html) { - post.blogBody = html; - resolve(); + post.categoryURL = category[0].url; + post.blogBody = html; + resolve(); }); }); }) @@ -148,14 +149,6 @@ module.exports= { html += "

" + htmlBlocks[i]; } - - html += "

\n" + - "

\n" + - "
\n"; - resolve(html); }).catch(function(error) @@ -243,6 +236,10 @@ module.exports= { promises.push(new Promise(function(res, rej) { + if(posts.length != 1) + { + templateContext.preview = true + } module.exports.generateBlogPost(posts[i], posts.length === 1 ? -1: 3).then(function(tempContext) { res(tempContext); @@ -254,8 +251,6 @@ module.exports= } } - //promises.push(require('../blog/renderNextBar').main(baseURL, currentPage, numOfPosts, blog.length)); - Promise.all(promises).then(function(posts) { templateContext.posts = posts; diff --git a/templates/blog/blogMain.html b/templates/blog/blogMain.html index 3e27815..d5a4345 100644 --- a/templates/blog/blogMain.html +++ b/templates/blog/blogMain.html @@ -5,31 +5,39 @@
{for post in posts} -
- {if post.hasPicture} - - {/if} +
+ {if post.hasPicture} + + {/if} + +
+

{post.name}

+
+ {post.published} +
-
-

{post.name}

-
- {post.published} -
+ {post.blogBody} - {post.blogBody} -
+ {if preview} +

+ Read More » +

+ {/if}
-
-
+ +
+
+
{else} -
-

Page Not Found

-
- Page not found -
+
+

Page Not Found

+
+ Page not found
-

+
+

{/for} {>paginationTemplate}