Skip to content

Commit 77a3482

Browse files
committed
fix: 修复未来日期的处理逻辑,确保只统计过去的文章数据
style: 调整热力图样式的列数
1 parent f2eff91 commit 77a3482

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

source/css/heat-map.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555

5656
.tiles {
57-
grid-column: 2/55;
57+
grid-column: 2/56;
5858
grid-row: 2/9;
5959

6060

source/js/heat_map.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,13 @@ function getLevelFromWordCount(totalCount) {
316316
return 4;
317317
}
318318

319+
var currentDate = new Date();
320+
319321
function transformArticlesData(articlesData) {
320322
const dailyStats = articlesData.reduce((map, { date, wordcount }) => {
323+
if (new Date(date) > currentDate) {
324+
return map; // 忽略未来的日期
325+
}
321326
const entry = map.get(date) ?? { count: 0, post: 0 };
322327
return map.set(date, {
323328
count: entry.count + wordcount,

0 commit comments

Comments
 (0)