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",
"id": "blogs_are_cool",
"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",
@ -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",
"id": "cross_platform_trainwreck",
"date": "7/6/2019",
"discuss": "https://twitter.com/Ellpeck/status/1147502654236573697"
"discuss": "https://twitter.com/Ellpeck/status/1147502654236573697",
"archived": true
},
{
"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",
"id": "lows",
"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",

View file

@ -25,10 +25,12 @@ fs.readFile(folder + "index.html", function (_, data) {
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>';
if (i < json.length - 1)
nav += '<a class="nav-item nav-link" href="/blog-' + json[i + 1].id + '">Next Post</a>';
let last = getAdjacentPost(json, i, -1);
if (last)
nav += '<a class="nav-item nav-link" href="/blog-' + last.id + '">Previous 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;
var c = "";
@ -36,12 +38,13 @@ fs.readFile(folder + "index.html", function (_, data) {
c += '<div class="blog-isolated">'
c += '<h1>' + post.name + '</h1>';
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 += '</div>';
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-' + post.id + '">Discuss this post</a>'
if (post.discuss)
c += '<a href="' + post.discuss + '" class="blog-discuss" id="blog-discuss-' + post.id + '">Discuss this post</a>'
c += '</div></div>';
document.getElementById("main").innerHTML = c;
@ -51,3 +54,14 @@ 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("");
for (let i = json.length - 1; i >= 0; i--) {
var obj = json[i];
if (obj.archived)
continue;
let p = "";
p += '<div class="card bg-light blog-entry rounded-0">';