Browse Source

Merge pull request #96 from jrtechs/html-title

Implemented Titles on Pages
pull/98/head
Jeffery Russell 4 years ago
committed by GitHub
parent
commit
5ec04c6eea
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 9 deletions
  1. +1
    -1
      blog/category.js
  2. +9
    -6
      blog/renderBlogPost.js
  3. +1
    -1
      templates/blog/blogMain.html
  4. +93
    -0
      templates/blog/header.html
  5. +5
    -1
      utils/pageBuilder.js

+ 1
- 1
blog/category.js View File

@ -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),

+ 9
- 6
blog/renderBlogPost.js View File

@ -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)
{

+ 1
- 1
templates/blog/blogMain.html View File

@ -1,4 +1,4 @@
{header}
{>header}
<br><br><br><br><br>
<div class="container">

+ 93
- 0
templates/blog/header.html View File

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!--fuck-->
{if title}
<title>Jrtechs: {title}</title>
{else}
<title>Jrtechs</title>
{/if}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--<link rel="stylesheet" href="/includes/css/purge.css" media="screen">-->
<link rel="stylesheet" href="/includes/css/bootstrap.css" media="screen">
<link rel="stylesheet" href="/includes/css/code.css" media="screen">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/styles/default.min.css">
<meta name="description" content="Blog of Jeffery Russell, featuring technical guides, and projects.">
<meta name="author" content="Jeffery Russell">
<link rel="apple-touch-icon" sizes="180x180" href="/includes/img/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/includes/img/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/includes/img/favicon/favicon-16x16.png">
<link rel="manifest" href="/includes/img/favicon/site.json">
<link rel="mask-icon" href="/includes/img/favicon/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<style>
html, body, h1, h2, h3, h4, h5, h6 {
font-family: 'Open Sans', sans-serif;
}
p{font-size:18px;}
</style>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
CommonHTML: { linebreaks: { automatic: true, width: "container" }, scale: 75 },
"HTML-CSS": { linebreaks: { automatic: true, width: "container" }, scale: 75 },
SVG: { linebreaks: { automatic: true, width: "container" }, scale: 75 }
});
</script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
</head>
<body>
<div class="navbar navbar-expand-lg navbar-dark fixed-top bg-primary" id="mainNav">
<div class="container">
<a class="navbar-brand" href="/">JrTechs</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/posts">Posts</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/photos">Photography</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a class="nav-link" href="https://jrtechs.me">Resume</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/jrtechs">Github</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.youtube.com/c/JrtechsNet">Youtube</a>
</li>
</ul>
</div>
</div>
</div>

+ 5
- 1
utils/pageBuilder.js View File

@ -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)])

Loading…
Cancel
Save