actually remove the anchors code lmao
All checks were successful
Web/pipeline/head This commit looks good
All checks were successful
Web/pipeline/head This commit looks good
This commit is contained in:
parent
052ef46de5
commit
ac692d402a
1 changed files with 4 additions and 7 deletions
|
@ -23,23 +23,21 @@ $.ajax({
|
||||||
function populateBlog(json, currentCategory) {
|
function populateBlog(json, currentCategory) {
|
||||||
const currCat = currentCategory;
|
const currCat = currentCategory;
|
||||||
|
|
||||||
let anchors = $('#blog-cat-anchors');
|
|
||||||
let archive = $('#blog-archive');
|
let archive = $('#blog-archive');
|
||||||
let list = $('#blog-list');
|
let list = $('#blog-list');
|
||||||
let cats = $('#blog-cats');
|
let cats = $('#blog-cats');
|
||||||
anchors.html("");
|
|
||||||
archive.html("");
|
archive.html("");
|
||||||
list.html("");
|
list.html("");
|
||||||
cats.html("");
|
cats.html("");
|
||||||
|
|
||||||
// force all and featured categories to be first
|
// force all and featured categories to be first
|
||||||
addCategory(json, cats, anchors, "All Posts", currCat);
|
addCategory(json, cats, "All Posts", currCat);
|
||||||
addCategory(json, cats, anchors, "Featured", currCat);
|
addCategory(json, cats, "Featured", currCat);
|
||||||
|
|
||||||
for (let i = json.length - 1; i >= 0; i--) {
|
for (let i = json.length - 1; i >= 0; i--) {
|
||||||
let post = json[i];
|
let post = json[i];
|
||||||
for (let cat of post.cat)
|
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)) {
|
if (currCat === "all-posts" || post.cat.some(c => c.toLowerCase().replace(" ", "-") === currCat)) {
|
||||||
let p = /*html*/ `
|
let p = /*html*/ `
|
||||||
<div class="card bg-light blog-entry rounded-0">
|
<div class="card bg-light blog-entry rounded-0">
|
||||||
|
@ -65,7 +63,7 @@ function populateBlog(json, currentCategory) {
|
||||||
populateBlog(json, "featured");
|
populateBlog(json, "featured");
|
||||||
}
|
}
|
||||||
|
|
||||||
function addCategory(json, cats, anchors, cat, currCat) {
|
function addCategory(json, cats, cat, currCat) {
|
||||||
let catId = cat.toLowerCase().replace(" ", "-");
|
let catId = cat.toLowerCase().replace(" ", "-");
|
||||||
let catAnchor = `blog-cat-${catId}`;
|
let catAnchor = `blog-cat-${catId}`;
|
||||||
if (!$(`#${catAnchor}`).length) {
|
if (!$(`#${catAnchor}`).length) {
|
||||||
|
@ -74,6 +72,5 @@ function addCategory(json, cats, anchors, cat, currCat) {
|
||||||
populateBlog(json, catId);
|
populateBlog(json, catId);
|
||||||
history.replaceState(null, null, `#blog-${catId}`);
|
history.replaceState(null, null, `#blog-${catId}`);
|
||||||
});
|
});
|
||||||
anchors.append( /*html*/ `<span class="anchor" id="blog-${catId}"></span>`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue