diff --git a/scripts/blog.js b/scripts/blog.js index 1a2d976..b489012 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -9,14 +9,8 @@ $.ajax({ url: "blog/src/posts.json", cache: false, success: function (json) { - let category = "Featured"; - let match = window.location.search.match(/cat=([^&]+)/); - if (match) { - let cat = decodeURI(match[1]); - if (json.some(p => p.cat.includes(cat))) - category = cat; - } - populateBlog(json, category); + let category = window.location.search.match(/cat=([^&]+)/); + populateBlog(json, category && decodeURI(category[1]) || "Featured"); forceToAnchor(); } }); @@ -58,6 +52,8 @@ function populateBlog(json, currCat) { if (!archive.html()) archive.html(`There are no archived ${currCat} posts.`); + if (!list.html()) + populateBlog(json, "Featured"); } function addCatButton(json, cats, cat, currCat) {