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
7 changes: 5 additions & 2 deletions src/components/WranglerCommand.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AnchorHeading from "./AnchorHeading.astro";
import { PackageManagers } from "starlight-package-managers";
import WranglerArg from "./WranglerArg.astro";
import Details from "./Details.astro";
import { marked } from "marked";

function getCommand(path: string) {
const segments = path.trim().split(/\s+/);
Expand Down Expand Up @@ -37,6 +38,8 @@ let { command, headingLevel, description } = props.parse(Astro.props);

const definition = getCommand(command);

description ??= definition.metadata.description;

if (!definition.args) {
throw new Error(`[WranglerCommand] "${command}" has no arguments`);
}
Expand All @@ -48,9 +51,9 @@ const positionals = definition.positionalArgs
.join(" ");
---

<AnchorHeading depth={headingLevel} title={command} />
<AnchorHeading depth={headingLevel} title={`\`${command}\``} />

<p>{description ? description : definition.metadata.description}</p>
<Fragment set:html={marked.parse(description)} />

<PackageManagers
pkg="wrangler"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import { WranglerCommand } from "~/components";
```mdx live
import { WranglerCommand } from "~/components";

<WranglerCommand command="deploy" />
<WranglerCommand
command="deploy"
description={"Deploy a [Worker](/workers/)"}
/>

<WranglerCommand command="d1 execute" />
```
Expand All @@ -33,4 +36,4 @@ import { WranglerCommand } from "~/components";
- `headingLevel` <Type text="boolean" /> <MetaInfo text="(default: 2) optional" />
- The heading level that the command name should be added at on the page, i.e `2` for a `h2`.
- `description` <Type text="string" /> <MetaInfo text="optional" />
- A description to render below the command heading. If not set, defaults to the value specified in the Wrangler help API.
- A description to render below the command heading. If not set, defaults to the value specified in the Wrangler help API.
Loading