diff --git a/changelog.njk b/changelog.njk
index 95fbd00..1a2cc96 100644
--- a/changelog.njk
+++ b/changelog.njk
@@ -99,8 +99,6 @@ withSidebar: false
{# Summary #}
- from the last days
- (all time)
@@ -127,8 +125,8 @@ function changelogApp() {
loadingMore: false,
commits: [],
categories: {},
- currentDays: 30,
- daysProgression: [30, 90, 180, 'all'],
+ currentPage: 1,
+ hasMore: false,
tabs: [
{ key: 'all', label: 'All' },
@@ -156,67 +154,59 @@ function changelogApp() {
},
get canLoadMore() {
- const idx = this.daysProgression.indexOf(this.currentDays);
- return idx >= 0 && idx < this.daysProgression.length - 1;
+ return this.hasMore;
},
async init() {
- await this.fetchChangelog(30);
+ await this.fetchChangelog(1);
},
- async fetchChangelog(days) {
+ async fetchChangelog(page) {
try {
- const since = days === 'all'
- ? null
- : new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
+ const limit = 50;
+ const newCommits = [];
+ let anyHasMore = false;
- const allCommits = [];
await Promise.all(GITEA_REPOS.map(async (repo) => {
- let page = 1;
- const limit = 50;
- while (true) {
- let url = `${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${repo}/commits?limit=${limit}&page=${page}`;
- if (since) url += `&since=${since}`;
- const r = await fetch(url);
- if (!r.ok) break;
- const commits = await r.json();
- if (!Array.isArray(commits) || commits.length === 0) break;
- const sinceDate = since ? new Date(since) : null;
- let pastCutoff = false;
- for (const c of commits) {
- const lines = (c.commit?.message || '').split('\n');
- const title = lines[0];
- const body = lines.slice(1).join('\n').trim();
- const date = c.created || c.commit?.author?.date;
- if (sinceDate && new Date(date) < sinceDate) { pastCutoff = true; continue; }
- allCommits.push({
- sha: c.sha.slice(0, 7),
- fullSha: c.sha,
- title,
- body: body || null,
- url: c.html_url,
- repoUrl: `${GITEA_URL}/${GITEA_ORG}/${repo}`,
- repoName: repo,
- date,
- author: c.commit?.author?.name || '',
- commitCategory: categorizeCommit(title),
- });
- }
- if (commits.length < limit || pastCutoff) break;
- page++;
+ const url = `${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${repo}/commits?limit=${limit}&page=${page}`;
+ const r = await fetch(url);
+ if (!r.ok) return;
+ const commits = await r.json();
+ if (!Array.isArray(commits)) return;
+ if (commits.length >= limit) anyHasMore = true;
+ for (const c of commits) {
+ const lines = (c.commit?.message || '').split('\n');
+ const title = lines[0];
+ const body = lines.slice(1).join('\n').trim();
+ newCommits.push({
+ sha: c.sha.slice(0, 7),
+ fullSha: c.sha,
+ title,
+ body: body || null,
+ url: c.html_url,
+ repoUrl: `${GITEA_URL}/${GITEA_ORG}/${repo}`,
+ repoName: repo,
+ date: c.commit?.author?.date || c.created,
+ author: c.commit?.author?.name || '',
+ commitCategory: categorizeCommit(title),
+ });
}
}));
- allCommits.sort((a, b) => new Date(b.date) - new Date(a.date));
+ const merged = page === 1
+ ? newCommits
+ : [...this.commits, ...newCommits];
+ merged.sort((a, b) => new Date(b.date) - new Date(a.date));
const categories = {};
- for (const c of allCommits) {
+ for (const c of merged) {
categories[c.commitCategory] = (categories[c.commitCategory] || 0) + 1;
}
- this.commits = allCommits;
+ this.commits = merged;
this.categories = categories;
- this.currentDays = days;
+ this.currentPage = page;
+ this.hasMore = anyHasMore;
} catch (err) {
console.error('Changelog error:', err);
} finally {
@@ -226,11 +216,8 @@ function changelogApp() {
},
async loadMore() {
- const idx = this.daysProgression.indexOf(this.currentDays);
- if (idx < 0 || idx >= this.daysProgression.length - 1) return;
- const nextDays = this.daysProgression[idx + 1];
this.loadingMore = true;
- await this.fetchChangelog(nextDays);
+ await this.fetchChangelog(this.currentPage + 1);
},
filteredCommits() {