diff --git a/README.md b/README.md index 438b6c3..ae28302 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,5 @@ # github-style -## 已知问题 - -- 往年热力图起始点错误 - -## TODO - -- 评论 -- 自定义菜单 -- 更多链接平台支持 - ## Init hugo site ```bash diff --git a/static/js/github-style.js b/static/js/github-style.js index 04a79b9..fc78658 100644 --- a/static/js/github-style.js +++ b/static/js/github-style.js @@ -173,12 +173,13 @@ function graph(year, posts, startDate, endDate) { } const monthPos = []; let startMonth = -1; + const weekday = startDate.getDay(); for (let i = 0; i < 53; i++) { html += ``; for (let j = 0; j < 7; j++) { - const date = new Date(startDate.getTime() + (i * 7 + j) * 24 * 60 * 60 * 1000); + const date = new Date(startDate.getTime() + (i * 7 + j - weekday) * 24 * 60 * 60 * 1000); const dataDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`; - if (date > endDate) { + if (date < startDate || date > endDate) { continue; }