diff --git a/scripts/blog.js b/scripts/blog.js index 05cdd23..e8ba2a1 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -26,6 +26,16 @@ $.getJSON("blog/posts.json", function (json) { } }); } + + if (window.location.hash.startsWith("#blog-")) { + var anchor = $(window.location.hash); + if (anchor.length) { + openBlogPost(window.location.hash.substring(6)); + $('html, body').animate({ + scrollTop: anchor.offset().top + }, 0) + } + } }); function openBlogPost(id) { diff --git a/scripts/main.js b/scripts/main.js index aeb9075..ddee4d5 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -13,9 +13,7 @@ $(function () { } } } - - let hash = window.location.hash; - openModals(hash); + openModals(window.location.hash); $('a').on('click', function () { openModals($(this).attr('href')); });; @@ -35,16 +33,6 @@ $(function () { window.location.hash = ""; location.reload(); }); - - if (hash.startsWith("#blog-")) { - var anchor = $(hash); - if (anchor.length) { - openBlogPost(hash.substring(6)); - $('html, body').animate({ - scrollTop: anchor.offset().top - }, 0) - } - } }); function getCookie(key) {