archived some posts

This commit is contained in:
Ellpeck 2020-05-06 19:54:21 +02:00
parent dbd7d77377
commit e739c04fb6
3 changed files with 30 additions and 11 deletions

View file

@ -3,7 +3,8 @@
"summary": "The first post and how I created it", "summary": "The first post and how I created it",
"id": "blogs_are_cool", "id": "blogs_are_cool",
"date": "2/17/2019", "date": "2/17/2019",
"discuss": "https://twitter.com/Ellpeck/status/1096937184601538566" "discuss": "https://twitter.com/Ellpeck/status/1096937184601538566",
"archived": true
}, },
{ {
"name": "Why You Should Mod Minecraft", "name": "Why You Should Mod Minecraft",
@ -31,7 +32,8 @@
"summary": "How moving from Java to C# taught me how horrible it is to create a cross-platform application with little to no knowledge or documentation", "summary": "How moving from Java to C# taught me how horrible it is to create a cross-platform application with little to no knowledge or documentation",
"id": "cross_platform_trainwreck", "id": "cross_platform_trainwreck",
"date": "7/6/2019", "date": "7/6/2019",
"discuss": "https://twitter.com/Ellpeck/status/1147502654236573697" "discuss": "https://twitter.com/Ellpeck/status/1147502654236573697",
"archived": true
}, },
{ {
"name": "Big Projects", "name": "Big Projects",
@ -87,7 +89,8 @@
"summary": "About depression and what it feels like when I don't know what to do with myself", "summary": "About depression and what it feels like when I don't know what to do with myself",
"id": "lows", "id": "lows",
"date": "10/20/2019", "date": "10/20/2019",
"discuss": "https://twitter.com/Ellpeck/status/1186028260838334471" "discuss": "https://twitter.com/Ellpeck/status/1186028260838334471",
"archived": true
}, },
{ {
"name": "Java Tutorial, Part 6: Inheritance", "name": "Java Tutorial, Part 6: Inheritance",

View file

@ -25,10 +25,12 @@ fs.readFile(folder + "index.html", function (_, data) {
var nav = ""; var nav = "";
nav += '<a class="nav-item nav-link" href="/#blog">Back to Main Page</a>'; nav += '<a class="nav-item nav-link" href="/#blog">Back to Main Page</a>';
if (i > 0) let last = getAdjacentPost(json, i, -1);
nav += '<a class="nav-item nav-link" href="/blog-' + json[i - 1].id + '">Previous Post</a>'; if (last)
if (i < json.length - 1) nav += '<a class="nav-item nav-link" href="/blog-' + last.id + '">Previous Post</a>';
nav += '<a class="nav-item nav-link" href="/blog-' + json[i + 1].id + '">Next Post</a>'; let next = getAdjacentPost(json, i, 1);
if (next)
nav += '<a class="nav-item nav-link" href="/blog-' + next.id + '">Next Post</a>';
document.getElementById("nav-items").innerHTML = nav; document.getElementById("nav-items").innerHTML = nav;
var c = ""; var c = "";
@ -36,12 +38,13 @@ fs.readFile(folder + "index.html", function (_, data) {
c += '<div class="blog-isolated">' c += '<div class="blog-isolated">'
c += '<h1>' + post.name + '</h1>'; c += '<h1>' + post.name + '</h1>';
c += '<div id="blog-post-' + post.id + '">' c += '<div id="blog-post-' + post.id + '">'
if (post.archived)
c += "<p><i>This post has been archived.</i></p>"
c += converter.makeHtml(content.toString()); c += converter.makeHtml(content.toString());
c += '</div>'; c += '</div>';
c += '<span class="text-muted project-status blog-isolated-status">' + post.date + "</span>"; c += '<span class="text-muted project-status blog-isolated-status">' + post.date + "</span>";
var discussLink = post.discuss; if (post.discuss)
if (discussLink) c += '<a href="' + post.discuss + '" class="blog-discuss" id="blog-discuss-' + post.id + '">Discuss this post</a>'
c += '<a href="' + discussLink + '" class="blog-discuss" id="blog-discuss-' + post.id + '">Discuss this post</a>'
c += '</div></div>'; c += '</div></div>';
document.getElementById("main").innerHTML = c; document.getElementById("main").innerHTML = c;
@ -50,4 +53,15 @@ fs.readFile(folder + "index.html", function (_, data) {
}); });
} }
}); });
}); });
function getAdjacentPost(json, index, move) {
while (true) {
index += move;
let post = json[index];
if (!post)
break;
if (!post.archived)
return post;
}
}

View file

@ -7,6 +7,8 @@ $.ajax({
list.html(""); list.html("");
for (let i = json.length - 1; i >= 0; i--) { for (let i = json.length - 1; i >= 0; i--) {
var obj = json[i]; var obj = json[i];
if (obj.archived)
continue;
let p = ""; let p = "";
p += '<div class="card bg-light blog-entry rounded-0">'; p += '<div class="card bg-light blog-entry rounded-0">';