File tree Expand file tree Collapse file tree 5 files changed +582
-0
lines changed
docs/style-guide/components Expand file tree Collapse file tree 5 files changed +582
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ import { Code } from " @astrojs/starlight/components" ;
3+ import Routes from " ~/content/dash-routes/index.json" ;
4+ ---
5+
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 >
Original file line number Diff line number Diff line change 1+ ---
2+ import { z } from " astro:schema" ;
3+ import { LinkButton } from " @astrojs/starlight/components" ;
4+ import Routes from " ~/content/dash-routes/index.json" ;
5+
6+ const props = z
7+ .object ({
8+ url: z .string (),
9+ })
10+ .strict ();
11+
12+ const { url } = props .parse (Astro .props );
13+
14+ const route = Routes .find ((route ) => route .deeplink === url );
15+
16+ if (! route ) {
17+ throw new Error (` [DashButton] No route found for ${url } ` );
18+ }
19+
20+ const { name } = route ;
21+
22+ const { href } = new URL (route .deeplink , " https://dash.cloudflare.com" );
23+ ---
24+
25+ <LinkButton href ={ href } >Go to { name } </LinkButton >
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export { default as ComponentUsage } from "./ComponentUsage.astro";
1414export { default as ComponentsUsage } from "./ComponentsUsage.astro" ;
1515export { default as CopyPageButton } from "./CopyPageButton.tsx" ;
1616export { default as CURL } from "./CURL.astro" ;
17+ export { default as DashButton } from "./DashButton.astro" ;
1718export { default as Description } from "./Description.astro" ;
1819export { default as Details } from "./Details.astro" ;
1920export { default as DirectoryListing } from "./DirectoryListing.astro" ;
You can’t perform that action at this time.
0 commit comments