I recently found out that this is a thing!
This commit is contained in:
parent
9235dfde09
commit
a22cc88b01
7 changed files with 38 additions and 42 deletions
27
node/blog.js
27
node/blog.js
|
@ -29,40 +29,39 @@ function createBlogPages(folder) {
|
|||
let json = JSON.parse(data);
|
||||
for (let i = 0; i < json.length; i++) {
|
||||
let post = json[i];
|
||||
let id = post["id"];
|
||||
fs.readFile(folder + "blog/" + id + ".md", function (_, content) {
|
||||
fs.readFile(folder + "blog/" + post.id + ".md", function (_, content) {
|
||||
let dom = new JSDOM(template);
|
||||
var document = dom.window.document;
|
||||
|
||||
document.title += " - " + post["name"];
|
||||
document.querySelector('meta[property="og:title"]').setAttribute("content", post["name"]);
|
||||
document.querySelector('meta[name="description"]').setAttribute("content", post["summary"]);
|
||||
document.querySelector('meta[property="og:description"]').setAttribute("content", post["summary"]);
|
||||
document.title += " - " + post.name;
|
||||
document.querySelector('meta[property="og:title"]').setAttribute("content", post.name);
|
||||
document.querySelector('meta[name="description"]').setAttribute("content", post.summary);
|
||||
document.querySelector('meta[property="og:description"]').setAttribute("content", post.summary);
|
||||
|
||||
var nav = "";
|
||||
nav += '<a class="nav-item nav-link" href="/#blog">Back to Main Page</a>';
|
||||
if (i > 0)
|
||||
nav += '<a class="nav-item nav-link" href="/blog-' + json[i - 1]["id"] + '">Previous Post</a>';
|
||||
nav += '<a class="nav-item nav-link" href="/blog-' + json[i - 1].id + '">Previous Post</a>';
|
||||
if (i < json.length - 1)
|
||||
nav += '<a class="nav-item nav-link" href="/blog-' + json[i + 1]["id"] + '">Next Post</a>';
|
||||
nav += '<a class="nav-item nav-link" href="/blog-' + json[i + 1].id + '">Next Post</a>';
|
||||
document.getElementById("nav-items").innerHTML = nav;
|
||||
|
||||
var c = "";
|
||||
c += '<div class="list-display rounded">';
|
||||
c += '<div class="blog-isolated">'
|
||||
c += '<h1>' + post["name"] + '</h1>';
|
||||
c += '<div id="blog-post-' + id + '">'
|
||||
c += '<h1>' + post.name + '</h1>';
|
||||
c += '<div id="blog-post-' + post.id + '">'
|
||||
c += converter.makeHtml(content.toString());
|
||||
c += '</div>';
|
||||
c += '<span class="text-muted project-status blog-isolated-status">' + post["date"] + "</span>";
|
||||
var discussLink = post["discuss"];
|
||||
c += '<span class="text-muted project-status blog-isolated-status">' + post.date + "</span>";
|
||||
var discussLink = post.discuss;
|
||||
if (discussLink)
|
||||
c += '<a href="' + discussLink + '" class="blog-discuss" id="blog-discuss-' + id + '">Discuss this post</a>'
|
||||
c += '<a href="' + discussLink + '" class="blog-discuss" id="blog-discuss-' + post.id + '">Discuss this post</a>'
|
||||
c += '</div></div>';
|
||||
document.getElementById("main").innerHTML = c;
|
||||
|
||||
let html = dom.serialize();
|
||||
fs.writeFile(folder + "blog-" + id + ".html", html, function (_, _) {});
|
||||
fs.writeFile(folder + "blog-" + post.id + ".html", html, function (_, _) {});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
11
node/rss.js
11
node/rss.js
|
@ -47,15 +47,14 @@ function createFeed(callback) {
|
|||
let json = JSON.parse(data);
|
||||
for (let i = json.length - 1; i >= 0; i--) {
|
||||
let post = json[i];
|
||||
let id = post["id"];
|
||||
let date = new Date(post["date"]);
|
||||
let date = new Date(post.date);
|
||||
|
||||
fs.readFile(__dirname + "/../blog/" + id + ".md", function (_, content) {
|
||||
fs.readFile(__dirname + "/../blog/" + post.id + ".md", function (_, content) {
|
||||
let html = converter.makeHtml(content.toString());
|
||||
feed.addItem({
|
||||
title: post["name"],
|
||||
link: "https://ellpeck.de/blog-" + id,
|
||||
description: post["summary"],
|
||||
title: post.name,
|
||||
link: "https://ellpeck.de/blog-" + post.id,
|
||||
description: post.summary,
|
||||
content: html,
|
||||
date: date,
|
||||
published: date
|
||||
|
|
|
@ -52,7 +52,7 @@ function refreshSitemap(folder) {
|
|||
|
||||
for (let post of json) {
|
||||
sitemap.add({
|
||||
url: "/blog-" + post["id"]
|
||||
url: "/blog-" + post.id
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ const questions = [{
|
|||
a: 'German, English, Java, JavaScript, C# and a bit of C, HTML and CSS.'
|
||||
},
|
||||
{
|
||||
"q": "How do you make games?",
|
||||
"a": "I usually use the .NET-based framework <a href=\"http://www.monogame.net/\">MonoGame</a> together with some libraries to make it a bit easier, including my own library, MLEM, which you can read about in the <a href=\"#projects\">Projects</a> section."
|
||||
q: "How do you make games?",
|
||||
a: "I usually use the .NET-based framework <a href=\"http://www.monogame.net/\">MonoGame</a> together with some libraries to make it a bit easier, including my own library, MLEM, which you can read about in the <a href=\"#projects\">Projects</a> section."
|
||||
},
|
||||
{
|
||||
q: 'What\'s your favorite programming language?',
|
||||
|
@ -80,8 +80,8 @@ const questions = [{
|
|||
let a = '';
|
||||
for (question of questions) {
|
||||
a += '<p>';
|
||||
a += '<strong>Q: ' + question["q"] + '</strong><br>';
|
||||
a += '<strong>A:</strong> ' + question["a"];
|
||||
a += '<strong>Q: ' + question.q + '</strong><br>';
|
||||
a += '<strong>A:</strong> ' + question.a;
|
||||
a += '</p>';
|
||||
}
|
||||
$('#about-list').html(a);
|
||||
|
|
|
@ -7,14 +7,13 @@ $.ajax({
|
|||
list.html("");
|
||||
for (let i = json.length - 1; i >= 0; i--) {
|
||||
var obj = json[i];
|
||||
let id = obj["id"];
|
||||
|
||||
let p = "";
|
||||
p += '<div class="card bg-light blog-entry rounded-0">';
|
||||
p += '<div class="card-body">';
|
||||
p += '<h2 class="card-title"><a class="blog-button" href="/blog-' + id + '">' + obj["name"] + '</a></h2>';
|
||||
p += '<div class="card-text text-muted blog-summary">' + obj["summary"] + '</div>';
|
||||
p += '<span class="text-muted project-status">' + obj["date"] + "</span>";
|
||||
p += '<h2 class="card-title"><a class="blog-button" href="/blog-' + obj.id + '">' + obj.name + '</a></h2>';
|
||||
p += '<div class="card-text text-muted blog-summary">' + obj.summary + '</div>';
|
||||
p += '<span class="text-muted project-status">' + obj.date + "</span>";
|
||||
p += '</div></div>';
|
||||
list.append(p);
|
||||
}
|
||||
|
|
|
@ -62,17 +62,16 @@ let p = '';
|
|||
for (project of projects) {
|
||||
p += '<div class="card bg-light project rounded-0">';
|
||||
p += '<div class="card-body">';
|
||||
p += '<img class="project-image" src="res/projects/' + project["icon"] + '.png" alt="">';
|
||||
p += '<img class="project-image" src="res/projects/' + project.icon + '.png" alt="">';
|
||||
|
||||
p += '<h4 class="card-title">' + project["name"] + '</h4>';
|
||||
p += '<p class="card-text">' + project["desc"] + '</p>';
|
||||
if (project["status"])
|
||||
p += '<span class="text-muted project-status">' + project["status"] + '</span>';
|
||||
p += '<h4 class="card-title">' + project.name + '</h4>';
|
||||
p += '<p class="card-text">' + project.desc + '</p>';
|
||||
if (project.status)
|
||||
p += '<span class="text-muted project-status">' + project.status + '</span>';
|
||||
|
||||
let links = project["links"];
|
||||
if (links) {
|
||||
for (let name in links) {
|
||||
p += '<a href="' + links[name] + '" class="card-link btn ' + (dark ? "btn-outline-light" : "btn-outline-info") + ' rounded-0">' + name + '</a>';
|
||||
if (project.links) {
|
||||
for (let name in project.links) {
|
||||
p += '<a href="' + project.links[name] + '" class="card-link btn ' + (dark ? "btn-outline-light" : "btn-outline-info") + ' rounded-0">' + name + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ const socials = [{
|
|||
|
||||
let s = '';
|
||||
for (social of socials) {
|
||||
s += '<a class="btn ' + (dark ? "btn-dark" : "btn-light") + ' social-button rounded-0" href="' + social["link"] + '"">';
|
||||
let icon = social["name"].toLowerCase();
|
||||
if (dark && social["darkIcon"])
|
||||
s += '<a class="btn ' + (dark ? "btn-dark" : "btn-light") + ' social-button rounded-0" href="' + social.link + '"">';
|
||||
let icon = social.name.toLowerCase();
|
||||
if (dark && social.darkIcon)
|
||||
icon += '_dark';
|
||||
s += '<img class="social-image" src="res/social/' + icon + '.png" alt="">';
|
||||
s += social["name"];
|
||||
s += social.name;
|
||||
s += '</a>'
|
||||
}
|
||||
$('#social-list').html(s);
|
||||
|
|
Loading…
Reference in a new issue