A cookie named dark with the value true or false that stores if you have dark mode enabled
A cookie named notification with the value true or false that stores if you have already closed the cookie notification that displays at the top of the page
-
A cookie named category that stores the category in the blog that you last selected
Due to widgets and embeds, additional information will be stored by other sites. Please refer to those sites' privacy policies for more information:
diff --git a/node/blog.js b/node/blog.js
index a3dfd17..cfadfd3 100644
--- a/node/blog.js
+++ b/node/blog.js
@@ -41,7 +41,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 2f82456..1a2d976 100644
--- a/scripts/blog.js
+++ b/scripts/blog.js
@@ -9,7 +9,14 @@ $.ajax({
url: "blog/src/posts.json",
cache: false,
success: function (json) {
- populateBlog(json, getCookie("category") || "Featured");
+ let category = "Featured";
+ let match = window.location.search.match(/cat=([^&]+)/);
+ if (match) {
+ let cat = decodeURI(match[1]);
+ if (json.some(p => p.cat.includes(cat)))
+ category = cat;
+ }
+ populateBlog(json, category);
forceToAnchor();
}
});
@@ -59,7 +66,7 @@ function addCatButton(json, cats, cat, currCat) {
cats.append( /*html*/ ``);
$(`#${catAnchor}`).on('click', function () {
populateBlog(json, cat);
- setCookie("category", cat, 365);
+ history.replaceState(null, null, `?cat=${cat}${location.hash}`);
});
}
}
\ No newline at end of file