Skip to content

Commit

Permalink
fix 排序紀錄
Browse files Browse the repository at this point in the history
  • Loading branch information
itshenrywu authored Jan 18, 2025
1 parent 7b89ab1 commit e52c735
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const ejs = require('ejs');

let levels = [{ name: '紅海', point: 0 }, { name: '銀海', point: 1600 }, { name: '金海', point: 6000 }, { name: '黑海', point: 10000 }];
let logs = JSON.parse(fs.readFileSync('./data/logs.json', 'utf8'));
logs.sort((a, b) => new Date(b.day) - new Date(a.day));

let totalPoint = 0;
logs = logs.reduceRight((acc, log) => {
Expand All @@ -22,4 +23,4 @@ const template = fs.readFileSync('./index.ejs', 'utf8');
const output = ejs.render(template, { logs, levels, totalPoint, target });

fs.writeFileSync('./index.html', output);
console.log('generate success!');
console.log('generate success!');

0 comments on commit e52c735

Please sign in to comment.