From a1431fdd9a09cc3b043607c0e210f968787df076 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 4 Apr 2021 02:01:25 +0200 Subject: [PATCH] small fixes --- scripts/blog.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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) {