From 028dc62e3b02a636e47f8c2b8484b3926f1a9cfb Mon Sep 17 00:00:00 2001 From: Track3 Date: Sun, 24 Mar 2019 11:45:41 +0800 Subject: [PATCH] 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 ++++++ assets/scss/style.scss | 5 +++++ layouts/_default/list.html | 2 +- .../js/js/main.js_d11fe7b62c27961c87ecd0f2490357b9.content | 2 +- .../js/js/main.js_d11fe7b62c27961c87ecd0f2490357b9.json | 2 +- .../style.scss_c16d144eee185fbddd582cd5e25a4fae.content | 2 +- .../scss/style.scss_c16d144eee185fbddd582cd5e25a4fae.json | 2 +- 7 files changed, 16 insertions(+), 5 deletions(-) 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(); diff --git a/assets/scss/style.scss b/assets/scss/style.scss index 9ff07e7..be2c149 100644 --- a/assets/scss/style.scss +++ b/assets/scss/style.scss @@ -408,6 +408,11 @@ p.img-404 { margin-right: 1.8em; font-size: 1.6em; @include dimmed; + + &:hover { + text-decoration: underline; + cursor: pointer; + } } .posts-list { diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 198911d..dc525d6 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -12,7 +12,7 @@ {{- end }} {{- range .Data.Pages.GroupByDate "2006" }}
-
{{ .Key }}
+
{{ .Key }}