fix(static): fix blank post activity

This commit is contained in:
yuweizzz
2022-01-15 22:45:49 +08:00
parent b8e6a9c7d0
commit 796ec24c82

View File

@@ -43,16 +43,18 @@ function switchYear(year) {
for (const item of contributions) { for (const item of contributions) {
if (item.date >= startDate && item.date <= endDate) { if (item.date >= startDate && item.date <= endDate) {
posts.push(item); posts.push(item);
if (!ms.includes(item.date.getMonth())) { const time = item.date.getFullYear().toString() + "-" + item.date.getMonth().toString();
ms.push(item.date.getMonth()); if (!ms.includes(time)) {
ms.push(time);
} }
} }
} }
posts.sort((a, b) => { return b - a }); posts.sort((a, b) => { return b - a });
document.querySelector('#posts-activity').innerHTML = ''; document.querySelector('#posts-activity').innerHTML = '';
for (const month of ms) { for (const time of ms) {
const node = document.createElement('div'); const node = document.createElement('div');
node.innerHTML = monthly(year, month, posts); const array = time.split("-");
node.innerHTML = monthly(array[0], Number(array[1]), posts);
document.querySelector('#posts-activity').appendChild(node); document.querySelector('#posts-activity').appendChild(node);
} }