Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 49 additions & 54 deletions src/components/changelog-next/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,79 +6,74 @@ import { getEntry, type CollectionEntry } from "astro:content";
import { StarlightIcon } from "..";
import HeroImage from "~/assets/images/changelog-next/hero.svg";

type Props = z.infer<typeof props>;
type Props = z.input<typeof props>;

const props = z.object({
entries: z.array(z.any()).optional(),
notes: z.any().array().default([]),
});

const { entries } = props.parse(Astro.props);
const { notes } = props.parse(Astro.props);

async function uniqueProducts(
entries?: Array<CollectionEntry<"changelogs-next">>,
notes: Array<CollectionEntry<"changelogs-next">>,
) {
const products = entries?.flatMap((entry) => entry.data.products ?? []);

const unique = [
...new Map(products?.map((product) => [product.id, product])).values(),
...new Set(notes.flatMap((e) => e.data.products.map((p) => p.id))),
];

return Promise.all(
unique.map(async (product) => {
return getEntry(product);
return getEntry("products", product)!;
}),
);
}

const products = await uniqueProducts(entries);
const products = await uniqueProducts(notes);
---

<div
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]"
class="bg-linear-to-r mb-16 ml-[calc(50%-50vw)] flex w-screen items-center justify-evenly border-b-2 bg-gradient-to-r from-[#FFE9CB99] to-[#FFFFFF99] p-4 dark:border-b-[#2C2C2C] dark:from-[#FBAD411F] dark:to-[#2C2C2C00] max-sm:flex-col-reverse sm:h-[18.75rem]"
>
<div class="flex justify-between self-center py-4 sm:py-0 md:w-[64rem]">
<div class="w-full self-center max-sm:text-center sm:items-start">
<div class="!mt-0 justify-items-center sm:hidden">
<Image src={HeroImage} alt="hero image" height="240" />
</div>
<h1 class="sm:!mt-0">Changelog</h1>
<p>
New updates and improvements at Cloudflare.
<span>
<a
href="/changelog-next/rss.xml"
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]"
>
Subscribe to RSS
<StarlightIcon
name="rss"
size="18px"
class="!inline align-text-top"
/>
</a>
</span>
</p>
{
entries && (
<div>
<select id="changelogs-next-filter" class="mt-2 h-8 w-52">
<option value="all">All products</option>
{products
.sort((a, b) => a.id.localeCompare(b.id))
.map(async (product) => {
return (
<option value={product.id}>
{product.data.product.title}
</option>
);
})}
</select>
</div>
)
}
</div>
<div class="!mt-0 hidden sm:block">
<Image src={HeroImage} alt="hero image" height="240" />
</div>
<div class="text-center sm:text-left">
<h1>Changelog</h1>
<p>
New updates and improvements at Cloudflare.
<a
href="/changelog-next/rss.xml"
class="dark:!hover:text-[#79B1FF] -mx-2 whitespace-nowrap px-2 text-[#056DFF] no-underline hover:rounded-[4px] hover:bg-[#DCEBFF] hover:!text-[#056DFF] dark:text-[#79B1FF] dark:hover:bg-[#002B66] max-sm:block"
>
Subscribe to RSS
<StarlightIcon name="rss" size="18px" class="!inline align-text-top" />
</a>
</p>
{
products.length > 0 && (
<div>
<select id="changelogs-next-filter" class="mt-2 h-8 w-52">
<option value="all">All products</option>
{products
.sort((a, b) => a.id.localeCompare(b.id))
.map(async (product) => {
return (
<option value={product.id}>
{product.data.product.title}
</option>
);
})}
</select>
</div>
)
}
</div>
<Image src={HeroImage} alt="hero image" height="240" class="!mt-0" />
</div>

<style is:global>
.sl-markdown-content {
margin-top: 0px !important;
}

.content-panel {
padding-top: 0 !important;
}
</style>
2 changes: 1 addition & 1 deletion src/components/changelog-next/ProductPills.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const data = await getEntries(products);
{
data.map((product) => (
<a href={product.data.product.url} class="no-underline">
<Badge text={product.data.product.title} class="ml-1" />
<Badge text={product.data.product.title} variant="tip" />
</a>
))
}
Expand Down
66 changes: 21 additions & 45 deletions src/pages/changelog-next/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -40,61 +40,37 @@ const props = {

<StarlightPage {...props}>
<Header />
<div class="w-full max-w-[50rem] justify-self-center px-4">
<div class="!mt-0 mb-10">
<a href="/changelog-next/" class="no-underline">
<span class="text-accent">← </span>
<span class="text-black">Back to all posts</span>
</a>
<div class="mt-0! mb-10">
<a href="/changelog-next/" class="no-underline">
<span class="text-accent">← </span>
<span class="text-black">Back to all posts</span>
</a>
</div>
<div>
<h2>{note.data.title}</h2>
<div>
<strong
>{format(note.data.date, "MMM dd, yyyy")}, {
format(note.data.date, "hh:mm a")
}</strong
>
<ProductPills products={note.data.products} />
</div>
<div class="w-full justify-self-center">
<h2>{note.data.title}</h2>
<div>
<strong
>{format(note.data.date, "MMM dd, yyyy")}, {
format(note.data.date, "hh:mm a")
}</strong
>
<ProductPills products={note.data.products} />
</div>
<div>
<Content />
</div>
<div>
<Content />
</div>
</div>
</StarlightPage>

<style>
:root {
--sl-content-width: 100% !important;

.sl-markdown-content {
margin-top: 0px !important;
}

.content-panel {
padding: 0px !important;
.sl-container {
--sl-content-width: 50rem !important;
margin-inline: auto !important;
}

#feedback-thumbs,
#footer-links {
justify-self: center;
}

.sl-markdown-content
:not(a, strong, em, del, span, input, code, br)
+ :not(
a,
strong,
em,
del,
span,
input,
code,
br,
:where(.not-content *)
) {
margin-top: 1.5rem;
justify-content: center;
}
}
</style>
132 changes: 54 additions & 78 deletions src/pages/changelog-next/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,50 @@ const props = {
---

<StarlightPage {...props}>
<Header entries={notes} />
<div
class="w-full max-w-[50rem] justify-self-center px-4 md:grid md:grid-cols-[15%_auto]"
>
{
notes.map(async (entry) => {
const date = format(entry.data.date, "MMM dd, yyyy");
const time = format(entry.data.date, "hh:mm a");
const productIds = JSON.stringify(
entry.data.products.map((product) => product.id),
);

const { Content } = await render(entry);

return (
<>
<div class="!mt-0" data-products={productIds}>
<p class="md:content-center md:pr-4 md:text-right md:leading-none">
<strong class="text-xs">{date}</strong>
<span class="text-xs">{time}</span>
</p>
</div>
<Steps>
<ol class="!mt-0 overflow-x-auto" data-products={productIds}>
<li class="!pb-16">
<div>
<Header notes={notes} />
{
notes.map(async (entry) => {
const date = format(entry.data.date, "MMM dd, yyyy");
const time = format(entry.data.date, "hh:mm a");
const productIds = JSON.stringify(
entry.data.products.map((product) => product.id),
);

const { Content } = await render(entry);

return (
<div class="!mt-0 sm:flex" data-products={productIds}>
<time
datetime={entry.data.date.toISOString()}
class="whitespace-nowrap leading-none sm:pr-4 sm:text-right"
>
<strong class="text-xs">{date}</strong>
<span class="text-xs sm:block">{time}</span>
</time>
<Steps>
<ol class="!mt-0 overflow-x-auto">
<li class="!pb-16">
<div>
<h3 class="leading-none">
<a
href={`/changelog-next/${entry.id}/`}
class="no-underline hover:underline"
class="mb-4 !text-black no-underline hover:underline"
>
<h3 class="mb-4 !leading-[36px] text-black">
{entry.data.title}
</h3>
{entry.data.title}
</a>
<ProductPills products={entry.data.products} />
</div>
<p>
<Content />
</p>
</li>
</ol>
</Steps>
</>
);
})
}
</div>
</h3>
<ProductPills products={entry.data.products} />
</div>
<p>
<Content />
</p>
</li>
</ol>
</Steps>
</div>
);
})
}
</StarlightPage>

<script>
Expand Down Expand Up @@ -111,52 +108,31 @@ const props = {

<style>
:root {
--sl-content-width: 100% !important;

.sl-markdown-content
:not(a, strong, em, del, span, input, code, br)
+ :not(
a,
strong,
em,
del,
span,
input,
code,
br,
:where(.not-content *)
) {
margin-top: 1.5rem;
}

.sl-markdown-content {
margin-top: 0px !important;
}

.content-panel {
padding: 0px !important;
.sl-container {
--sl-content-width: 50rem !important;
margin-inline: auto !important;
}

.feedback-prompt-content {
display: none !important;
}

#footer-links {
justify-self: center;
justify-content: center;
}
}

.sl-steps {
--bullet-size: 24px !important;
.sl-steps {
--bullet-size: 24px !important;

& > li {
padding-inline-start: calc(var(--bullet-size) + 2.5rem) !important;
& > li {
padding-inline-start: calc(var(--bullet-size) + 2.5rem) !important;

&::before {
content: "•" !important;
font-size: calc(var(--bullet-size) * 2) !important;
line-height: calc(var(--bullet-size) / 1.5) !important;
color: var(--orange-accent-200) !important;
}
&::before {
content: "•" !important;
font-size: calc(var(--bullet-size) * 2) !important;
line-height: calc(var(--bullet-size) / 1.5) !important;
color: var(--orange-accent-200) !important;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/changelog-next/rss.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const GET: APIRoute = async () => {
return rss({
title: "Changelogs",
description: `Cloudflare changelogs`,
site: "https://developers.cloudflare.com",
site: "https://developers.cloudflare.com/changelog-next/",
items: notes.map((entry) => {
return {
title: entry.data.title,
Expand Down
Loading