Skip to content

Commit 069378c

Browse files
committed
[Docs Site] Limit /changelog/ to 5 entries per product
1 parent aa36adf commit 069378c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/pages/changelog/index.astro

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,28 @@ import { productsByGroup } from "~/util/products";
1313
1414
import { render } from "astro:content";
1515
16-
const notes = await getChangelogs({
16+
let notes = await getChangelogs({
1717
filter: (entry) => !entry.data.hidden,
1818
});
1919
20+
const seen = new Map<string, number>();
21+
22+
notes = notes.flatMap((note) => {
23+
const products = note.data.products.map((product) => product.id);
24+
25+
for (const product of products) {
26+
const previous = seen.get(product) || 0;
27+
28+
seen.set(product, previous + 1);
29+
30+
if (previous >= 5) {
31+
return [];
32+
}
33+
}
34+
35+
return note;
36+
});
37+
2038
const props = {
2139
frontmatter: {
2240
title: "Changelogs",

0 commit comments

Comments
 (0)