Skip to content

Add live download counter to website#55

Merged
MartinDejmal merged 2 commits into
mainfrom
copilot/add-download-counter-website
May 5, 2026
Merged

Add live download counter to website#55
MartinDejmal merged 2 commits into
mainfrom
copilot/add-download-counter-website

Conversation

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor

The download section had no visibility into how many times mdedit has been downloaded. This adds a live counter that aggregates download counts across all GitHub release assets.

Changes

  • www/index.html — inserts a pill badge above the download cards showing total downloads; counter is populated asynchronously and falls back to on failure. Paginated fetch handles repositories with >100 releases.
let hasMore = true;
while (hasMore) {
  const res = await fetch(
    `https://api.github.com/repos/MartinDejmal/mdedit/releases?per_page=100&page=${page}`
  );
  if (!res.ok) { console.error('download counter: GitHub API responded with', res.status); break; }
  const releases = await res.json();
  for (const release of releases) {
    for (const asset of release.assets) { total += asset.download_count; }
  }
  hasMore = releases.length === 100;
  page++;
}
  • www/style.css — styles for .download-stat-badge pill, .download-stat-value (bold white number), and .download-stat-label; visually consistent with the existing dark download section palette.

Copilot AI linked an issue May 5, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/MartinDejmal/mdedit/sessions/4be67f89-98bb-473c-92e3-726c7ffd3c3e

Co-authored-by: MartinDejmal <18679101+MartinDejmal@users.noreply.github.com>
Copilot AI changed the title [WIP] Add download counter to website Add live download counter to website May 5, 2026
Copilot AI requested a review from MartinDejmal May 5, 2026 06:57
@MartinDejmal

Copy link
Copy Markdown
Owner

@copilot is the counter persistent? Where is the current count stored?

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

@copilot is the counter persistent? Where is the current count stored?

The counter is not stored anywhere in this repository. It reads download counts directly from GitHub's own Releases API (/repos/MartinDejmal/mdedit/releases). GitHub tracks how many times each release asset has been downloaded on its servers — the download_count field on every asset is maintained by GitHub automatically. Each page load fetches the current total live from the API, so there's no separate storage or database needed on our side.

@MartinDejmal MartinDejmal marked this pull request as ready for review May 5, 2026 07:35
@MartinDejmal MartinDejmal merged commit 02c3435 into main May 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add download counter to website

2 participants