From d171f55eeaa5de4f6a3d04a1a2fd98b657d3151d Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 31 Mar 2021 17:03:25 +0200 Subject: [PATCH] fixed the "all posts" category not being recognized --- scripts/blog.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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) {