diff --git a/scripts/blog.js b/scripts/blog.js index b8ea61c..00f19c1 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -15,7 +15,9 @@ $.ajax({ } }); -function populateBlog(json, currCat) { +function populateBlog(json, currentCategory) { + const currCat = currentCategory; + let anchors = $('#blog-cat-anchors'); let archive = $('#blog-archive'); let list = $('#blog-list'); @@ -33,8 +35,7 @@ function populateBlog(json, currCat) { let post = json[i]; for (let cat of post.cat) addCategory(json, cats, anchors, cat, currCat); - let catIds = post.cat.map(c => c.toLowerCase().replace(" ", "-")); - if (currCat === "all-posts" || catIds.includes(currCat)) { + if (currCat === "all-posts" || post.cat.some(c => c.toLowerCase().replace(" ", "-") === currCat)) { let p = /*html*/ `
@@ -56,7 +57,7 @@ function populateBlog(json, currCat) { if (!archive.html()) archive.html(`There are no archived posts in this category.`); if (!list.html()) - populateBlog(json, "Featured"); + populateBlog(json, "featured"); } function addCategory(json, cats, anchors, cat, currCat) {