Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metrics.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"total_views": 1022,
"lastUpdated": "2025-07-11T19:59:55.567Z"
"lastUpdated": "2025-07-11T20:07:49.421Z"
}
12 changes: 7 additions & 5 deletions update_repo_views_counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,23 @@ function updateMetricsFile(total_views) {
function updateMarkdownBadges(total_views) {
const refreshDate = new Date().toISOString().split('T')[0];
const badgeRegex = /<!-- START BADGE -->[\s\S]*?<!-- END BADGE -->/g;

const badgeBlock = `<!-- START BADGE -->
<div align="center">
<img src="https://img.shields.io/badge/Total%20views-${total_views}-limegreen" alt="Total views">
<p>Refresh Date: ${refreshDate}</p>
</div>
<!-- END BADGE -->`;

const markdownFiles = findMarkdownFiles('.');
const markdownFiles = findMarkdownFiles('.'); // Find all Markdown files in the directory
markdownFiles.forEach(file => {
let content = fs.readFileSync(file, 'utf-8');
    if (badgeRegex.test(content)) {
if (badgeRegex.test(content)) {
const updated = content.replace(badgeRegex, badgeBlock);
fs.writeFileSync(file, updated);
console.log(`Updated badge in ${file}`);
} else {
console.log(`Badge block not found in ${file}`);
}
});
}
Expand All @@ -68,9 +70,9 @@ function findMarkdownFiles(dir) {
const filePath = path.join(dir, file);
const stat = fs.statSync(filePath);
if (stat && stat.isDirectory()) {
results = results.concat(findMarkdownFiles(filePath));
results = results.concat(findMarkdownFiles(filePath)); // Recursively search subdirectories
} else if (file.endsWith('.md')) {
results.push(filePath);
results.push(filePath); // Add Markdown files to the results
}
});
return results;
Expand Down