From f053ef54e7e1dc06f46b117c697fbf1c09389a89 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 17 Feb 2019 13:07:19 +0100 Subject: [PATCH] add a "discuss this post" link option --- blog/posts.json | 3 ++- scripts/blog.js | 12 +++++++++++- style.css | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/blog/posts.json b/blog/posts.json index 786a4a0..b577287 100644 --- a/blog/posts.json +++ b/blog/posts.json @@ -1,5 +1,6 @@ [{ "name": "Blogs are cool, I think", "id": "blogs_are_cool", - "date": "2/17/2019" + "date": "2/17/2019", + "discuss": "https://twitter.com/Ellpeck/status/1096937184601538566" }] \ No newline at end of file diff --git a/scripts/blog.js b/scripts/blog.js index e8ba2a1..ae8cd69 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -10,8 +10,11 @@ $.getJSON("blog/posts.json", function (json) { p += '
'; p += '
'; p += '

' + obj["name"] + '

'; - p += '' + obj["date"] + ""; p += '
'; + p += '' + obj["date"] + ""; + var discussLink = obj["discuss"]; + if (discussLink) + p += '' p += '
'; list.append(p); @@ -19,6 +22,9 @@ $.getJSON("blog/posts.json", function (json) { var post = $("#blog-post-" + id); if (post.html() !== "") { post.html(""); + var discuss = $("#blog-discuss-" + id); + if (discuss.length) + discuss.html(""); history.pushState(null, null, "#blog"); } else { openBlogPost(id); @@ -42,5 +48,9 @@ function openBlogPost(id) { $.get("blog/" + id + ".md", function (markdown) { let html = converter.makeHtml(markdown); $("#blog-post-" + id).html(html); + + var discuss = $("#blog-discuss-" + id); + if (discuss.length) + discuss.html("Discuss this post"); }); } \ No newline at end of file diff --git a/style.css b/style.css index 10eba44..d147aa8 100644 --- a/style.css +++ b/style.css @@ -96,6 +96,10 @@ body { margin-top: 20px; } +.blog-discuss { + padding-top: 15px; +} + .footer { bottom: 0; line-height: 30px;