Browse Source

Moved button html gen to template and (closes #88)

pull/96/head
jrtechs 4 years ago
parent
commit
41ac3e7673
2 changed files with 35 additions and 32 deletions
  1. +8
    -13
      blog/renderBlogPost.js
  2. +27
    -19
      templates/blog/blogMain.html

+ 8
- 13
blog/renderBlogPost.js View File

@ -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 += "<p>" + htmlBlocks[i];
}
html += " <div style=\"\">\n" +
" <p class='text-center'><button class=\"btn btn-secondary btn-lg " +
"w3-padding-large w3-white w3-border\" onclick=\"location.href='" +
"http://jrtechs.net/" + categoryURL + "/" + postURL +
"'\"><b>READ MORE &raquo;</b></button></p>\n" +
" </div>\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;

+ 27
- 19
templates/blog/blogMain.html View File

@ -5,31 +5,39 @@
<div class="row">
<div class="col-md-8 col-12">
{for post in posts}
<div class="blogPost">
{if post.hasPicture}
<img src="/blogContent/headerImages/{post.picture_url}" style="width:100%;">
{/if}
<div class="blogPost">
{if post.hasPicture}
<img src="/blogContent/headerImages/{post.picture_url}" style="width:100%;">
{/if}
<div class="p-4">
<h3><b>{post.name}</b></h3>
<h5>
<span class="w3-opacity">{post.published}</span>
</h5>
<div class="p-4">
<h3><b>{post.name}</b></h3>
<h5>
<span class="w3-opacity">{post.published}</span>
</h5>
{post.blogBody}
{post.blogBody}
</div>
{if preview}
<p class="text-center">
<a class="btn btn-secondary btn-lg text-white"
href="https://jrtechs.net/{post.categoryURL}/{post.url}"><b>Read More &raquo;</b></a>
</p>
{/if}
</div>
<br>
<br>
</div>
<br>
<br>
{else}
<div class="row p-lg-0">
<h1 class="align-content-center">Page Not Found</h1>
<div class="align-content-center">
<img src="/includes/img/404.jpg" alt="Page not found" width="70%" />
</div>
<div class="row p-lg-0">
<h1 class="align-content-center">Page Not Found</h1>
<div class="align-content-center">
<img src="/includes/img/404.jpg" alt="Page not found" width="70%" />
</div>
<br><br>
</div>
<br><br>
{/for}
{>paginationTemplate}

Loading…
Cancel
Save