fixed the "all posts" category not being recognized
All checks were successful
Web/pipeline/head This commit looks good

This commit is contained in:
Ell 2021-03-31 17:03:25 +02:00
parent 7470a20886
commit d171f55eea

View file

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