diff --git a/src/components/changelog/ProductSelect.tsx b/src/components/changelog/ProductSelect.tsx index d963f289585f6b..aefb5a0eb3a216 100644 --- a/src/components/changelog/ProductSelect.tsx +++ b/src/components/changelog/ProductSelect.tsx @@ -65,6 +65,22 @@ export default function ProductSelect({ products, groups }: Props) { select.value = option.value; select.dispatchEvent(event); } + + const search = document.querySelector( + "#changelog-search-button", + ); + + if (search) { + if ( + options + .find((opt) => opt.label === "Products") + ?.options?.includes(option) + ) { + search.href = `/search/?contentType=Changelog+entry&product=${encodeURIComponent(option.label)}`; + } else { + search.href = `/search/?contentType=Changelog+entry`; + } + } }; return ( diff --git a/src/pages/changelog/index.astro b/src/pages/changelog/index.astro index 2ad05cfc80505d..72fc6fd2065052 100644 --- a/src/pages/changelog/index.astro +++ b/src/pages/changelog/index.astro @@ -13,10 +13,28 @@ import { productsByGroup } from "~/util/products"; import { render } from "astro:content"; -const notes = await getChangelogs({ +let notes = await getChangelogs({ filter: (entry) => !entry.data.hidden, }); +const seen = new Map(); + +notes = notes.flatMap((note) => { + const products = note.data.products.map((product) => product.id); + + for (const product of products) { + const previous = seen.get(product) || 0; + + seen.set(product, previous + 1); + + if (previous >= 5) { + return []; + } + } + + return note; +}); + const props = { frontmatter: { title: "Changelogs", @@ -48,7 +66,7 @@ const props = { return (
= 10 }]} + class:list={["mt-0! sm:flex", { "hidden!": idx >= 50 }]} data-products={JSON.stringify( productIds.concat( productGroups.map((group) => @@ -86,12 +104,13 @@ const props = { }) }
- + Search for historical entries +
@@ -100,10 +119,6 @@ const props = { "#changelogs-next-filter", ); - const button = document.querySelector( - "#changelogs-next-button", - ); - const url = new URL(window.location.href); if (filter && url.searchParams.has("product")) { @@ -126,21 +141,6 @@ const props = { return products.includes(value); } - button?.addEventListener("click", () => { - const hidden = [ - ...document.querySelectorAll("[data-products]"), - ] - .filter( - (e) => - e.classList.contains("hidden!") && filterByProduct(e, filter!.value), - ) - .slice(0, 10); - - hidden.forEach((e) => e.classList.remove("hidden!")); - - hideButton(); - }); - function updateFilter() { const entries = [ ...document.querySelectorAll("[data-products]"), @@ -152,7 +152,7 @@ const props = { const filtered = entries .filter((e) => filterByProduct(e, value)) - .slice(0, 10); + .slice(0, 5); for (const entry of entries) { const show = filtered.includes(entry); @@ -173,27 +173,6 @@ const props = { } history.replaceState(null, "", url.href); - - hideButton(); - } - - function hideButton() { - const entries = [ - ...document.querySelectorAll("[data-products]"), - ]; - - if (entries.length === 0) return; - - const filtered = entries.filter((p) => filterByProduct(p, filter!.value)); - - const visible = filtered.filter((p) => !p.classList.contains("hidden!")); - const hidden = filtered.length - visible.length; - - if (hidden > 0) { - button!.classList.remove("hidden!"); - } else { - button!.classList.add("hidden!"); - } }