diff --git a/blog/category.js b/blog/category.js index 80fe24d..8a2e5ab 100644 --- a/blog/category.js +++ b/blog/category.js @@ -22,7 +22,7 @@ module.exports= var page = request.query.page; const category = requestURL.split("/").join(""); - + templateContext["title"] = category; sql.getPostsFromCategory(category).then(function(posts) { Promise.all([blogBodyRenderer.renderBatchOfPosts(requestURL, posts, page, 5, templateContext), diff --git a/blog/renderBlogPost.js b/blog/renderBlogPost.js index 420d81f..46e90a6 100644 --- a/blog/renderBlogPost.js +++ b/blog/renderBlogPost.js @@ -178,7 +178,6 @@ module.exports= }, - pandocWrapper: function(markdownContents, pandocArgs) { return new Promise((resolve, reject)=> @@ -208,7 +207,7 @@ module.exports= /** - * Renders a bunch of blog post previews to the user + * Renders a bunch of blog post previews to the user * * @param baseURL-- url of the page * @param posts -- sql data about the blog to render @@ -236,12 +235,12 @@ 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) { + if(posts.length != 1) + { + templateContext.preview = true + } res(tempContext); }).catch(function(error) { @@ -254,6 +253,10 @@ module.exports= Promise.all(promises).then(function(posts) { templateContext.posts = posts; + if(posts.length == 1) + templateContext.title = posts[0].name; + else if(currentPage != 1 && baseURL === "/") + templateContext.title = "page " + currentPage; resolve(); }).catch(function(error) { diff --git a/templates/blog/blogMain.html b/templates/blog/blogMain.html index d5a4345..8657082 100644 --- a/templates/blog/blogMain.html +++ b/templates/blog/blogMain.html @@ -1,4 +1,4 @@ -{header} +{>header}




diff --git a/templates/blog/header.html b/templates/blog/header.html new file mode 100644 index 0000000..04caf1e --- /dev/null +++ b/templates/blog/header.html @@ -0,0 +1,93 @@ + + + + + + {if title} + Jrtechs: {title} + {else} + Jrtechs + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utils/pageBuilder.js b/utils/pageBuilder.js index d4900a6..820b0d5 100644 --- a/utils/pageBuilder.js +++ b/utils/pageBuilder.js @@ -12,11 +12,15 @@ const url = require('url'); const TEMPLATE_FILE="blog/blogMain.html"; +const HEADER_TEMPLATE_FILE="blog/header.html"; +const HEADER_TEMPLATE_KEY="header"; + const PAGINATION_TEMPLATE_KEY = "paginationTemplate"; const PAGINATION_TEMPLATE_FILE = "blog/paginationBar.html"; + module.exports = { /** @@ -143,7 +147,7 @@ module.exports = var templateContext = Object(); Promise.all([includes.fetchTemplate(TEMPLATE_FILE), includes.includeInObject(PAGINATION_TEMPLATE_KEY, templateContext, "templates/" + PAGINATION_TEMPLATE_FILE), - includes.printHeader(templateContext), + includes.includeInObject(HEADER_TEMPLATE_KEY, templateContext, "templates/" + HEADER_TEMPLATE_FILE), includes.printFooter(templateContext), templateFiller(filename, request, templateContext), require("../blog/sidebar.js").main(templateContext)])