add a "discuss this post" link option
This commit is contained in:
parent
76be31d38e
commit
f053ef54e7
3 changed files with 17 additions and 2 deletions
|
@ -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"
|
||||
}]
|
|
@ -10,8 +10,11 @@ $.getJSON("blog/posts.json", function (json) {
|
|||
p += '<div class="card bg-light blog-entry rounded-0">';
|
||||
p += '<div class="card-body">';
|
||||
p += '<a class="blog-button" id="blog-button-' + id + '"><h2 class="card-title">' + obj["name"] + '</h2></a>';
|
||||
p += '<span class="text-muted project-status">' + obj["date"] + "</span>";
|
||||
p += '<div class="card-text" id="blog-post-' + id + '"></div>';
|
||||
p += '<span class="text-muted project-status">' + obj["date"] + "</span>";
|
||||
var discussLink = obj["discuss"];
|
||||
if (discussLink)
|
||||
p += '<a href="' + discussLink + '" class="blog-discuss" id="blog-discuss-' + id + '"></a>'
|
||||
p += '</div></div>';
|
||||
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");
|
||||
});
|
||||
}
|
|
@ -96,6 +96,10 @@ body {
|
|||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.blog-discuss {
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
bottom: 0;
|
||||
line-height: 30px;
|
||||
|
|
Loading…
Reference in a new issue