Skip to content

Commit 92bcf04

Browse files
authored
[Dash Button] Expand to ZT routes (#26216)
1 parent b12854a commit 92bcf04

File tree

5 files changed

+942
-18
lines changed

5 files changed

+942
-18
lines changed
Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
---
22
import { Code } from "@astrojs/starlight/components";
3-
import Routes from "~/content/dash-routes/index.json";
3+
import AnchorHeading from "./AnchorHeading.astro";
4+
import CoreRoutes from "~/content/dash-routes/core.json";
5+
import ZeroTrustRoutes from "~/content/dash-routes/zero-trust.json";
46
---
57

6-
<ul>
7-
{
8-
Routes.map((route) => (
9-
<li>
10-
<strong>{(route.parent ?? []).concat(route.name).join(" > ")}</strong>
11-
<br />
12-
<Code lang="mdx" code={`<DashButton url="${route.deeplink}" />`} />
13-
</li>
14-
))
15-
}
16-
</ul>
8+
<div>
9+
<AnchorHeading depth={3} title="Core Routes" />
10+
<ul>
11+
{
12+
CoreRoutes.map((route) => (
13+
<li>
14+
<strong>{(route.parent ?? []).concat(route.name).join(" > ")}</strong>
15+
<br />
16+
<Code lang="mdx" code={`<DashButton url="${route.deeplink}" />`} />
17+
</li>
18+
))
19+
}
20+
</ul>
21+
22+
<AnchorHeading depth={3} title="Zero Trust Routes" />
23+
<ul>
24+
{
25+
ZeroTrustRoutes.map((route) => (
26+
<li>
27+
<strong>{route.name}</strong>
28+
<br />
29+
<Code lang="mdx" code={`<DashButton url="${route.deeplink}" />`} />
30+
</li>
31+
))
32+
}
33+
</ul>
34+
</div>

src/components/DashButton.astro

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
---
22
import { z } from "astro:schema";
33
import { LinkButton } from "@astrojs/starlight/components";
4-
import Routes from "~/content/dash-routes/index.json";
4+
import CoreRoutes from "~/content/dash-routes/core.json";
5+
import ZeroTrustRoutes from "~/content/dash-routes/zero-trust.json";
56
67
const props = z
78
.object({
89
url: z.string(),
10+
zeroTrust: z.boolean().optional().default(false),
11+
buttonName: z.string().optional(),
912
})
1013
.strict();
1114
12-
const { url } = props.parse(Astro.props);
15+
const { url, zeroTrust, buttonName } = props.parse(Astro.props);
1316
14-
const route = Routes.find((route) => route.deeplink === url);
17+
const routes = zeroTrust ? ZeroTrustRoutes : CoreRoutes;
18+
19+
const route = routes.find((route) => route.deeplink === url);
1520
1621
if (!route) {
1722
throw new Error(`[DashButton] No route found for ${url}`);
1823
}
1924
20-
const { name } = route;
25+
const name = buttonName ?? route.name;
26+
const baseUrl = zeroTrust
27+
? "https://one.dash.cloudflare.com"
28+
: "https://dash.cloudflare.com";
2129
22-
const { href } = new URL(route.deeplink, "https://dash.cloudflare.com");
30+
let { href } = new URL(route.deeplink, baseUrl);
2331
---
2432

2533
<LinkButton href={href} icon="external" target="_blank"
File renamed without changes.

0 commit comments

Comments
 (0)