-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
02d9156
commit f4055a7
Showing
7 changed files
with
190 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useState } from "react"; | ||
import { Clipboard } from "lucide-react"; | ||
import { DiceCmdMeta } from "@/data/command"; | ||
|
||
export default function CommandPage({ title, syntax, body, url }: DiceCmdMeta) { | ||
const [copied, setCopied] = useState(false); | ||
|
||
const handleCopy = () => { | ||
navigator.clipboard.writeText(syntax); | ||
setCopied(true); | ||
setTimeout(() => setCopied(false), 2000); | ||
}; | ||
|
||
return ( | ||
<div className="p-6 bg-gray-100 text-white rounded-lg shadow-lg border border-gray-700 mb-4"> | ||
<h2 className="text-gray-700 text-2xl font-semibold mb-4">{title}</h2> | ||
|
||
<div className="flex items-center justify-between mb-4 pt-4"> | ||
<h3 className="text-gray-700 text-2xl font-semibold">Syntax</h3> | ||
<div className="flex flex-row"> | ||
{copied && ( | ||
<div className="text-green-500 text-sm"> | ||
Copied! | ||
</div> | ||
)} | ||
<button | ||
onClick={handleCopy} | ||
className="text-gray-500 hover:text-gray-700 flex items-center ml-4" | ||
title="Copy to clipboard" | ||
> | ||
<Clipboard className="w-5 h-5" /> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div | ||
className="bg-gray-200 rounded-lg relative overflow-x-auto p-4" | ||
> | ||
<code className="font-mono text-sm whitespace-pre text-gray-700 inline-block min-w-full"> | ||
{syntax} | ||
</code> | ||
</div> | ||
|
||
<h2 className="text-gray-700 text-2xl font-semibold pt-4 mb-4"> | ||
Description | ||
</h2> | ||
<div className="bg-gray-200 p-4 rounded-lg mb-4"> | ||
<p className="text-md text-gray-900">{body}</p> | ||
</div> | ||
|
||
<a | ||
href={url} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="text-blue-400 hover:text-blue-300 underline font-medium transition-colors duration-200" | ||
> | ||
View Documentation | ||
</a> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// this file will contain the command definitions | ||
|
||
export interface DiceCmdMeta { | ||
title: string; | ||
syntax: string; | ||
body : string; | ||
url?: string; | ||
} | ||
|
||
export const DiceCmds: { [key: string]: DiceCmdMeta } = { | ||
SET: { | ||
title: "SET", | ||
syntax: "SET key value [NX | XX] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL ]", | ||
body: "The SET command in DiceDB is used to set the value of a key. If the key already holds a value, it is overwritten, regardless of its type. This is one of the most fundamental operations in DiceDB as it allows for both creating and updating key-value pairs.", | ||
url: "https://dicedb.io/commands/set/" | ||
}, | ||
GET: { | ||
title: "GET", | ||
syntax: "GET key", | ||
body: "The GET command retrieves the value of a key. If the key does not exist, nil is returned.", | ||
url: "https://dicedb.io/commands/get/" | ||
} | ||
}; |
Oops, something went wrong.