redirect legacy anchors in js
All checks were successful
Web/pipeline/head This commit looks good

This commit is contained in:
Ell 2021-10-11 14:07:57 +02:00
parent 4b661cf0a7
commit cfe0ae6e88
3 changed files with 9 additions and 3 deletions

View file

@ -10,7 +10,7 @@ $(".blog-cat-button").on("click", function () {
history.replaceState(null, null, `#blog-${tag}`);
});
let category = window.location.hash.match(/#blog-(.+)/);
let category = location.hash.match(/#blog-(.+)/);
openCategory(category && decodeURI(category[1]));
function openCategory(name) {

View file

@ -2,6 +2,12 @@ const dark = getCookie("dark") === "true";
if (dark)
addStyle("/style/dark.css");
// redirect legacy anchors
if (/#privacy\/?/.test(location.hash))
location.href = "/privacy";
if (/#impressum\/?/.test(location.hash))
location.href = "/impressum";
$(function () {
$('.navbar-collapse a').on('click', function () {
$('.navbar-collapse').collapse('hide');
@ -15,7 +21,7 @@ $(function () {
mode.prop('checked', dark);
mode.on('click', function () {
setCookie("dark", $(this).prop('checked'), 365);
window.location.hash = "";
location.hash = "";
location.reload();
});
});

View file

@ -10,7 +10,7 @@ function setCookie(key, value, days) {
}
function forceToAnchor(customAnchor) {
let anchor = customAnchor || window.location.hash;
let anchor = customAnchor || location.hash;
// this is probably a terrible hack
if (anchor.startsWith("#")) {
let element = $(anchor);