|
| 1 | +--- |
| 2 | +import { Image } from "astro:assets"; |
| 3 | +import { z } from "astro:schema"; |
| 4 | +import { getEntry, reference, type CollectionEntry } from "astro:content"; |
| 5 | +
|
| 6 | +import { StarlightIcon } from ".."; |
| 7 | +import HeroImage from "~/assets/images/release-notes/hero.svg"; |
| 8 | +import { releaseNotesSchema } from "~/schemas"; |
| 9 | +
|
| 10 | +type Props = z.infer<typeof props>; |
| 11 | +
|
| 12 | +const props = z.object({ |
| 13 | + entries: z.array(z.any()).optional(), |
| 14 | +}); |
| 15 | +
|
| 16 | +const { entries } = props.parse(Astro.props); |
| 17 | +
|
| 18 | +async function uniqueProducts( |
| 19 | + entries?: Array<CollectionEntry<"release-notes">>, |
| 20 | +) { |
| 21 | + const products = entries?.flatMap((entry) => entry.data.products ?? []); |
| 22 | +
|
| 23 | + const unique = [...new Set(products)]; |
| 24 | +
|
| 25 | + return Promise.all( |
| 26 | + unique.map(async (product) => { |
| 27 | + return getEntry(product); |
| 28 | + }), |
| 29 | + ); |
| 30 | +} |
| 31 | +
|
| 32 | +const products = await uniqueProducts(entries); |
| 33 | +--- |
| 34 | + |
| 35 | +<div |
| 36 | + class="mb-16 flex w-full justify-center border-b-2 border-b-[#EAEAEA] bg-gradient-to-r from-[#FFE9CB99] to-[#FFFFFF99] dark:border-b-[#2C2C2C] dark:from-[#FBAD411F] dark:to-[#2C2C2C00] sm:h-[300px]" |
| 37 | +> |
| 38 | + <div class="flex justify-between self-center py-4 sm:py-0 md:w-[64rem]"> |
| 39 | + <div class="w-full self-center max-sm:text-center sm:items-start"> |
| 40 | + <div class="!mt-0 justify-items-center sm:hidden"> |
| 41 | + <Image src={HeroImage} alt="hero image" height="240" /> |
| 42 | + </div> |
| 43 | + <h1 class="sm:!mt-0">Changelog</h1> |
| 44 | + <p> |
| 45 | + New updates and improvements at Cloudflare. |
| 46 | + <span> |
| 47 | + <a |
| 48 | + href="/release-notes/rss.xml" |
| 49 | + class="px-2 text-[#056DFF] no-underline hover:rounded-[4px] hover:bg-[#DCEBFF] hover:!text-[#056DFF] dark:text-[#79B1FF] dark:hover:bg-[#002B66] dark:hover:!text-[#79B1FF]" |
| 50 | + > |
| 51 | + Subscribe to RSS |
| 52 | + <StarlightIcon |
| 53 | + name="rss" |
| 54 | + size="18px" |
| 55 | + class="!inline align-text-top" |
| 56 | + /> |
| 57 | + </a> |
| 58 | + </span> |
| 59 | + </p> |
| 60 | + { |
| 61 | + entries && ( |
| 62 | + <div> |
| 63 | + <select id="release-notes-filter" class="mt-2 h-8 w-52"> |
| 64 | + <option value="all">All products</option> |
| 65 | + {products |
| 66 | + .sort((a, b) => a.id.localeCompare(b.id)) |
| 67 | + .map(async (product) => { |
| 68 | + return ( |
| 69 | + <option value={product.id}> |
| 70 | + {product.data.product.title} |
| 71 | + </option> |
| 72 | + ); |
| 73 | + })} |
| 74 | + </select> |
| 75 | + </div> |
| 76 | + ) |
| 77 | + } |
| 78 | + </div> |
| 79 | + <div class="!mt-0 hidden sm:block"> |
| 80 | + <Image src={HeroImage} alt="hero image" height="240" /> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | +</div> |
0 commit comments