From 028dc62e3b02a636e47f8c2b8484b3926f1a9cfb Mon Sep 17 00:00:00 2001 From: Track3 Date: Sun, 24 Mar 2019 11:45:41 +0800 Subject: Add anchor points to post list page * post-year now has anchor point, you can click on it or input url with hash tag to jump to a specific year. * See #39 --- assets/js/main.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'assets/js') diff --git a/assets/js/main.js b/assets/js/main.js index bd0ad59..5f0a47c 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -86,6 +86,12 @@ if (header !== null) { listen('#img-btn', "click", showImg); listen('.bg-img', "click", hideImg); + document.querySelectorAll('.post-year').forEach((ele)=> { + ele.addEventListener('click', () => { + window.location.hash = '#' + ele.id; + }); + }); + window.addEventListener('scroll', throttle(() => { autoHideHeader(); -- cgit v1.2.3