Skip to content

Commit

Permalink
Fix install commands
Browse files Browse the repository at this point in the history
  • Loading branch information
iipanda committed Oct 26, 2024
1 parent 807abb0 commit 9c89ac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/www/content/docs/components/chat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The Chat component provides a complete chat interface with message history, typi
<TabsContent value="cli">

```bash
npx shadcn@latest add http://localhost:3333/r/chat.json
npx shadcn@latest add chat
```

</TabsContent>
Expand Down
15 changes: 11 additions & 4 deletions apps/www/lib/rehype-npm-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { UnistNode, UnistTree } from "types/unist"
import { visit } from "unist-util-visit"

import { siteConfig } from "@/config/site"

export function rehypeNpmCommand() {
return (tree: UnistTree) => {
visit(tree, (node: UnistNode) => {
Expand Down Expand Up @@ -50,13 +52,18 @@ export function rehypeNpmCommand() {
!node.properties?.["__rawString__"]?.startsWith("npx create-")
) {
const npmCommand = node.properties?.["__rawString__"]
node.properties["__npmCommand__"] = npmCommand
node.properties["__yarnCommand__"] = npmCommand
node.properties["__pnpmCommand__"] = npmCommand.replace(
const parts = npmCommand.split(" ")
const componentName = parts.pop()
parts.push(`${siteConfig.url}/r/${componentName}.json`)
const modifiedCommand = parts.join(" ")

node.properties["__npmCommand__"] = modifiedCommand
node.properties["__yarnCommand__"] = modifiedCommand
node.properties["__pnpmCommand__"] = modifiedCommand.replace(
"npx",
"pnpm dlx"
)
node.properties["__bunCommand__"] = npmCommand.replace(
node.properties["__bunCommand__"] = modifiedCommand.replace(
"npx",
"bunx --bun"
)
Expand Down

0 comments on commit 9c89ac0

Please sign in to comment.