actually remove the anchors code lmao
All checks were successful
Web/pipeline/head This commit looks good

This commit is contained in:
Ell 2021-06-24 00:23:02 +02:00
parent 052ef46de5
commit ac692d402a

View file

@ -23,23 +23,21 @@ $.ajax({
function populateBlog(json, currentCategory) {
const currCat = currentCategory;
let anchors = $('#blog-cat-anchors');
let archive = $('#blog-archive');
let list = $('#blog-list');
let cats = $('#blog-cats');
anchors.html("");
archive.html("");
list.html("");
cats.html("");
// force all and featured categories to be first
addCategory(json, cats, anchors, "All Posts", currCat);
addCategory(json, cats, anchors, "Featured", currCat);
addCategory(json, cats, "All Posts", currCat);
addCategory(json, cats, "Featured", currCat);
for (let i = json.length - 1; i >= 0; i--) {
let post = json[i];
for (let cat of post.cat)
addCategory(json, cats, anchors, cat, currCat);
addCategory(json, cats, cat, currCat);
if (currCat === "all-posts" || post.cat.some(c => c.toLowerCase().replace(" ", "-") === currCat)) {
let p = /*html*/ `
<div class="card bg-light blog-entry rounded-0">
@ -65,7 +63,7 @@ function populateBlog(json, currentCategory) {
populateBlog(json, "featured");
}
function addCategory(json, cats, anchors, cat, currCat) {
function addCategory(json, cats, cat, currCat) {
let catId = cat.toLowerCase().replace(" ", "-");
let catAnchor = `blog-cat-${catId}`;
if (!$(`#${catAnchor}`).length) {
@ -74,6 +72,5 @@ function addCategory(json, cats, anchors, cat, currCat) {
populateBlog(json, catId);
history.replaceState(null, null, `#blog-${catId}`);
});
anchors.append( /*html*/ `<span class="anchor" id="blog-${catId}"></span>`);
}
}