Skip to content

Commit 6206a2e

Browse files
committed
[Docs Site] Release notes PoC
1 parent 19d1e26 commit 6206a2e

File tree

20 files changed

+687
-22
lines changed

20 files changed

+687
-22
lines changed

.prettierrc.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
/** @type {import("prettier").Config} */
33
export default {
4-
plugins: ["prettier-plugin-astro"],
4+
plugins: ["prettier-plugin-astro", "prettier-plugin-tailwindcss"],
55
useTabs: true,
66
overrides: [
77
{

package-lock.json

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"playwright": "^1.49.0",
7373
"prettier": "^3.4.2",
7474
"prettier-plugin-astro": "^0.14.1",
75+
"prettier-plugin-tailwindcss": "^0.6.9",
7576
"puppeteer": "^23.10.1",
7677
"react": "^18.3.1",
7778
"react-dom": "^18.3.1",

src/assets/images/release-notes/hero.svg

Lines changed: 111 additions & 0 deletions
Loading
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
import { getEntries } from "astro:content";
3+
import { reference } from "astro:content";
4+
import { z } from "astro:schema";
5+
6+
type Props = z.infer<typeof props>;
7+
8+
const props = z.object({
9+
products: z.array(reference("products")),
10+
});
11+
12+
const { products } = Astro.props;
13+
14+
const data = await getEntries(products);
15+
---
16+
17+
<div class="flex flex-row gap-2">
18+
{
19+
data.map((product) => (
20+
<a href={product.data.product.url} class="no-underline">
21+
<span class="ml-1 rounded-full bg-orange-200 px-2 py-0.5 text-xs text-orange-900">
22+
{product.data.product.title}
23+
</span>
24+
</a>
25+
))
26+
}
27+
</div>

src/components/overrides/Footer.astro

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if (
9292
<ul class="list-none pl-0">
9393
{links.map((link) => (
9494
<li>
95-
<a href={link.href} class="no-underline text-white">
95+
<a href={link.href} class="text-white no-underline">
9696
{link.text}
9797
</a>
9898
</li>
@@ -103,15 +103,15 @@ if (
103103
</div>
104104
</div>
105105
<div>
106-
<ul class="flex gap-x-4 text-xs list-outside pl-0 justify-center text-gray-600 dark:!text-gray-400">
106+
<ul class="flex list-outside justify-center gap-x-4 pl-0 text-xs text-gray-600 dark:!text-gray-400">
107107
<li class="list-none text-gray-600 dark:text-gray-400">
108108
2024 Cloudflare, Inc.
109109
</li>
110110
{homepageLegalLinks.map(([text, href]) => (
111111
<li>
112112
<a
113113
href={href}
114-
class="no-underline text-gray-600 dark:!text-gray-400"
114+
class="text-gray-600 no-underline dark:!text-gray-400"
115115
>
116116
{text}
117117
</a>
@@ -126,17 +126,17 @@ if (
126126
) : (
127127
<>
128128
<Default {...Astro.props} />
129-
<div class="items-center flex flex-wrap">
129+
<div id="footer-links" class="flex flex-wrap items-center">
130130
{Object.entries(links).map(([text, href]) => (
131131
<a
132132
href={href}
133-
class="mx-2 my-2 text-xs text-black dark:text-white decoration-accent-600 dark:decoration-accent-200"
133+
class="mx-2 my-2 text-xs text-black decoration-accent-600 dark:text-white dark:decoration-accent-200"
134134
>
135135
<span>{text}</span>
136136
</a>
137137
))}
138138
{isProduction && (
139-
<div class="mx-2 my-2 text-xs text-black dark:text-white underline decoration-accent-600 dark:decoration-accent-200">
139+
<div class="mx-2 my-2 text-xs text-black underline decoration-accent-600 dark:text-white dark:decoration-accent-200">
140140
<OneTrust />
141141
</div>
142142
)}

src/components/overrides/PageTitle.astro

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const summary = Astro.props.entry.data.summary;
2121
2222
const slug = Astro.props.entry.slug;
2323
24-
const showBreadcrumbs = !["products"].includes(slug);
25-
2624
const breadcrumbProps: Record<string, any> = {
2725
crumbs: [
2826
{
@@ -73,10 +71,11 @@ for (let i = 0; i < segments.length; i++) {
7371
// Currently the officially sanctioned way to alter behaviour on specific routes
7472
// https://starlight.astro.build/guides/overriding-components/#only-override-on-specific-pages
7573
const hideTitle = Astro.props.hideTitle;
74+
const hideBreadcrumbs = Astro.props.hideBreadcrumbs;
7675
---
7776

7877
{
79-
showBreadcrumbs && (
78+
!hideBreadcrumbs && (
8079
<Breadcrumbs {...breadcrumbProps}>
8180
<svg
8281
slot="separator"
@@ -119,3 +118,13 @@ const hideTitle = Astro.props.hideTitle;
119118
--color-link-breadcrumbs: var(--sl-color-text-accent);
120119
}
121120
</style>
121+
122+
{ hideTitle && hideBreadcrumbs &&
123+
<style>
124+
main {
125+
.content-panel:first-of-type {
126+
display: none;
127+
}
128+
}
129+
</style>
130+
}

src/components/overrides/Sidebar.astro

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,21 @@ async function handleLink(link: Link): Promise<Link> {
157157
return link;
158158
}
159159
160-
filtered.entries = await Promise.all(
161-
filtered.entries.map((entry) => {
162-
if (entry.type === "group") {
163-
return handleGroup(entry);
164-
} else {
165-
return handleLink(entry);
166-
}
167-
}),
168-
);
160+
if (currentSection !== "release-notes") {
161+
filtered.entries = await Promise.all(
162+
filtered.entries.map((entry) => {
163+
if (entry.type === "group") {
164+
return handleGroup(entry);
165+
} else {
166+
return handleLink(entry);
167+
}
168+
}),
169+
);
169170
170-
filtered.entries = filtered.entries.sort(sortGroup);
171+
filtered.entries = filtered.entries.sort(sortGroup);
171172
172-
filtered.entries[0].label = "Overview";
173+
filtered.entries[0].label = "Overview";
174+
}
173175
174176
const lookupProductTitle = async (slug: string) => {
175177
const segments = slug.split("/");
@@ -183,6 +185,10 @@ const lookupProductTitle = async (slug: string) => {
183185
return `${entryData?.data?.title} (Learning Paths)`;
184186
}
185187
188+
if (product === "release-notes") {
189+
return "Release notes";
190+
}
191+
186192
const entryData = await getEntry("products", product);
187193
188194
return entryData?.data?.product?.title ?? "Unknown";

src/components/overrides/SocialIcons.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const links = Object.entries({
2727

2828
<style>
2929
:root {
30-
--sl-icon-color: var(--sl-color-text);
30+
.social-icons {
31+
--sl-icon-color: var(--sl-color-text);
32+
}
3133
}
3234
</style>

0 commit comments

Comments
 (0)