Skip to content

Commit

Permalink
Fix the word count problem, which was counted by date, should be coun…
Browse files Browse the repository at this point in the history
…ted by posts instead
  • Loading branch information
ramsayleung committed Oct 13, 2024
1 parent 1aceb8f commit 9b21c4c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion layouts/shortcodes/heatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
var postObj = new Map();
postObj.set("title", {{ .Title }});
postObj.set("link", {{ .RelPermalink }});
postObj.set("wordCount", {{ .WordCount }});
var wordCount = {{ .WordCount }};
var data = postsByDate.get(date);
if (data === undefined) {
Expand Down Expand Up @@ -168,14 +169,14 @@
enterable: true,
formatter: function (params) {
const thousandWordsText = {{ default "EN" (.Get "language")}} === "EN" ? 'k words': '千字';
const thousandWords = (params.data[1]/1000.0).toFixed(1);
const date = params.data[0];
const posts = postsByDate.get(date).get("posts");
var content = `${date}`;
for (const [i, post] of posts.entries()) {
content += "<br>";
var link = post.get("link");
var title = post.get("title");
const thousandWords = (post.get("wordCount")/1000.0).toFixed(1);
content += `<a href="${link}" target="_blank">${title} | ${thousandWords}${thousandWordsText}</a>`
}
return content;
Expand Down

0 comments on commit 9b21c4c

Please sign in to comment.