diff --git a/index.html b/index.html index fdfae4a..963d136 100644 --- a/index.html +++ b/index.html @@ -164,6 +164,7 @@ +
diff --git a/node/blog.js b/node/blog.js index 74a8faf..099a3e9 100644 --- a/node/blog.js +++ b/node/blog.js @@ -42,7 +42,7 @@ fs.readFile(`${folder}index.html`, function (_, html) { document.querySelector('meta[property="og:description"]').setAttribute("content", post.summary); document.getElementById("nav-items").innerHTML = /*html*/ ` - Back to Main Page + Back to Main Page ${last ? /*html*/ `Previous ${post.cat[0]} Post` : ""} ${next ? /*html*/ `Next ${post.cat[0]} Post` : ""} `; diff --git a/scripts/blog.js b/scripts/blog.js index b489012..b8ea61c 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -9,29 +9,32 @@ $.ajax({ url: "blog/src/posts.json", cache: false, success: function (json) { - let category = window.location.search.match(/cat=([^&]+)/); - populateBlog(json, category && decodeURI(category[1]) || "Featured"); + let category = window.location.hash.match(/#blog-(.+)/); + populateBlog(json, category && decodeURI(category[1]) || "featured"); forceToAnchor(); } }); function populateBlog(json, currCat) { + 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 - addCatButton(json, cats, "All Posts", currCat); - addCatButton(json, cats, "Featured", currCat); + addCategory(json, cats, anchors, "All Posts", currCat); + addCategory(json, cats, anchors, "Featured", currCat); for (let i = json.length - 1; i >= 0; i--) { let post = json[i]; for (let cat of post.cat) - addCatButton(json, cats, cat, currCat); - if (currCat === "All Posts" || post.cat.includes(currCat)) { + addCategory(json, cats, anchors, cat, currCat); + let catIds = post.cat.map(c => c.toLowerCase().replace(" ", "-")); + if (currCat === "all-posts" || catIds.includes(currCat)) { let p = /*html*/ `