Skip to content

Commit

Permalink
Merge pull request #578 from DIVD-NL/572-fix-date-structure-in-contri…
Browse files Browse the repository at this point in the history
…bute-page

572 - Added dots to larger numbers in update_stats & made it update both languages
  • Loading branch information
MagicLegend authored Aug 29, 2024
2 parents 90ff33e + e358d19 commit d4f363c
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions scripts/update_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@ async function updateMarkdown() {
totalIps += stats.ips;
});

// Read the existing markdown file
const filePath = 'content/block/_index.en.md';
const fileContent = fs.readFileSync(filePath, 'utf8');
['en', 'nl'].forEach((lang) => {
// Read the existing markdown file
const filePath = `content/block/_index.${lang}.md`;
const fileContent = fs.readFileSync(filePath, 'utf8');

// Parse the front matter
const parsed = matter(fileContent);
const frontMatter = parsed.data;
// Parse the front matter
const parsed = matter(fileContent);
const frontMatter = parsed.data;

// Update the front matter with the aggregated data
frontMatter.mission.members = totalMembers.toString();
frontMatter.mission.totalcases = totalCases.toString();
frontMatter.mission.ips = totalIps;
// Update the front matter with the aggregated data
frontMatter.mission.members = totalMembers.toLocaleString('nl-NL');
frontMatter.mission.totalcases = totalCases.toLocaleString('nl-NL');
frontMatter.mission.ips = totalIps.toLocaleString('nl-NL');

// Convert back to markdown with updated front matter
const newContent = matter.stringify(parsed.content, frontMatter);
// Convert back to markdown with updated front matter
const newContent = matter.stringify(parsed.content, frontMatter);

// Write the updated content back to the file
fs.writeFileSync(filePath, newContent, 'utf8');
// Write the updated content back to the file
fs.writeFileSync(filePath, newContent, 'utf8');

console.log('Markdown file updated successfully!');
console.log(`${lang} file updated successfully!`);
});
} catch (error) {
console.error('Error fetching data:', error);
}
Expand Down

0 comments on commit d4f363c

Please sign in to comment.