diff --git a/src/pages/changelog/index.astro b/src/pages/changelog/index.astro
index d0cc271739f47e..39c0724214bb23 100644
--- a/src/pages/changelog/index.astro
+++ b/src/pages/changelog/index.astro
@@ -89,7 +89,7 @@ const props = {
@@ -114,37 +114,26 @@ const props = {
filter?.addEventListener("change", updateFilter);
- button?.addEventListener("click", () => {
- const entries = [
- ...document.querySelectorAll("[data-products]"),
- ];
-
- if (!entries) return;
-
- const value = filter!.value;
-
- const hidden = entries
- .filter((e) => {
- if (e.style.display !== "none") {
- return false;
- }
-
- if (value === "all") {
- return true;
- }
-
- if (!e.dataset.products) {
- return false;
- }
+ function filterByProduct(e: HTMLElement, value: string): boolean {
+ if (value === "all") {
+ return true;
+ }
- const products: string[] = JSON.parse(e.dataset.products);
+ if (!e.dataset.products) {
+ return false;
+ }
- if (products.includes(value)) {
- return true;
- }
+ const products: string[] = JSON.parse(e.dataset.products);
+ return products.includes(value);
+ }
- return false;
- })
+ button?.addEventListener("click", () => {
+ const hidden = [
+ ...document.querySelectorAll("[data-products]"),
+ ]
+ .filter(
+ (e) => e.style.display === "none" && filterByProduct(e, filter!.value),
+ )
.slice(0, 10);
hidden.forEach((e) => (e.style.display = ""));
@@ -162,24 +151,8 @@ const props = {
const value = filter!.value;
const filtered = entries
- .filter((e) => {
- if (value === "all") {
- return true;
- }
-
- if (!e.dataset.products) {
- return false;
- }
-
- const products: string[] = JSON.parse(e.dataset.products);
-
- if (products.includes(value)) {
- return true;
- }
-
- return false;
- })
- .slice(0, 5);
+ .filter((e) => filterByProduct(e, value))
+ .slice(0, 10);
for (const entry of entries) {
const show = filtered.includes(entry);
@@ -211,30 +184,12 @@ const props = {
if (entries.length === 0) return;
- const filtered = entries.filter((p) => {
- const value = filter!.value;
-
- if (value === "all") {
- return true;
- }
-
- if (!p.dataset.products) {
- return false;
- }
-
- const products: string[] = JSON.parse(p.dataset.products);
-
- if (!products.includes(value)) {
- return false;
- }
-
- return true;
- });
+ const filtered = entries.filter((p) => filterByProduct(p, filter!.value));
const visible = filtered.filter((p) => p.style.display !== "none");
const hidden = filtered.length - visible.length;
- if (hidden >= 10) {
+ if (hidden > 0) {
button!.style.display = "";
} else {
button!.style.display = "none";