MCPcopy
hub / github.com/agentsmd/agents.md / CodeExample

Function CodeExample

components/CodeExample.tsx:126–207  ·  view source on GitHub ↗
({
  code,
  href,
  compact = false,
  heightClass,
  centerVertically = false,
}: CodeExampleProps)

Source from the content-addressed store, hash-verified

124 * Markdown block for AGENTS.md examples.
125 */
126export default function CodeExample({
127 code,
128 href,
129 compact = false,
130 heightClass,
131 centerVertically = false,
132}: CodeExampleProps) {
133 const md = code ?? EXAMPLE_AGENTS_MD;
134 const [copied, setCopied] = React.useState(false);
135
136 const copyToClipboard = async () => {
137 try {
138 await navigator.clipboard.writeText(md);
139 setCopied(true);
140 setTimeout(() => setCopied(false), 2000);
141 } catch (err) {
142 console.error("Failed to copy to clipboard:", err);
143 }
144 };
145
146 const content = (
147 <>
148 <div className="relative">
149 <button
150 onClick={copyToClipboard}
151 className={`absolute right-3 p-2 rounded-md bg-transparent text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors z-10 cursor-pointer ${
152 centerVertically ? "top-1/2 -translate-y-1/2" : "top-3"
153 }`}
154 aria-label="Copy to clipboard"
155 >
156 {copied ? (
157 <svg
158 className="w-4 h-4"
159 fill="none"
160 stroke="currentColor"
161 viewBox="0 0 24 24"
162 >
163 <path
164 strokeLinecap="round"
165 strokeLinejoin="round"
166 strokeWidth={2}
167 d="M5 13l4 4L19 7"
168 />
169 </svg>
170 ) : (
171 <CopyIcon className="w-4 h-4" />
172 )}
173 </button>
174 <pre
175 className={`relative rounded-lg bg-white dark:bg-black text-gray-800 dark:text-gray-100 text-xs leading-6 overflow-x-auto p-4 ${
176 centerVertically ? "flex items-center" : ""
177 } ${
178 heightClass
179 ? heightClass
180 : compact
181 ? ""
182 : "min-h-[250px] max-h-[500px]"
183 } border border-gray-200 dark:border-gray-700 shadow-sm`}

Callers

nothing calls this directly

Calls 1

parseMarkdownFunction · 0.85

Tested by

no test coverage detected