diff --git a/scripts/blog.js b/scripts/blog.js index 58acca4..34e1872 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -4,19 +4,17 @@ $("#blog-archive-button").on("click", function () { $(this).html((archive.is(":visible") ? "Hide" : "Show") + " archived posts"); }); -let blogData; $.ajax({ dataType: "json", url: "blog/src/posts.json", cache: false, success: function (json) { - blogData = json; - populateBlog("All"); + populateBlog(json, "All"); forceToAnchor(); } }); -function populateBlog(cat) { +function populateBlog(json, cat) { let archive = $('#blog-archive'); let list = $('#blog-list'); let cats = $('#blog-cats'); @@ -24,10 +22,10 @@ function populateBlog(cat) { list.html(""); cats.html(""); - addCatButton(cats, "All"); - for (let i = blogData.length - 1; i >= 0; i--) { - var obj = blogData[i]; - addCatButton(cats, obj.cat); + addCatButton(json, cats, "All"); + for (let i = json.length - 1; i >= 0; i--) { + var obj = json[i]; + addCatButton(json, cats, obj.cat); if (cat == "All" || obj.cat == cat) { let p = ""; p += '