mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
* improvement(landing, blog): SEO and GEO optimization * improvement(docs): ui/ux cleanup * chore(blog): remove unused buildBlogJsonLd export and wordCount schema field * fix(blog): stack related posts vertically on mobile and fill all suggestion slots - Add flex-col sm:flex-row and matching border classes to related posts nav for consistent mobile stacking with the main blog page - Remove score > 0 filter in getRelatedPosts so it falls back to recent posts when there aren't enough tag matches - Align description text color with main page cards
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
import { CodeBlock as FumadocsCodeBlock } from 'fumadocs-ui/components/codeblock'
|
|
import { Check, Copy } from 'lucide-react'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
export function CodeBlock(props: React.ComponentProps<typeof FumadocsCodeBlock>) {
|
|
const [copied, setCopied] = useState(false)
|
|
|
|
const handleCopy = async (text: string) => {
|
|
await navigator.clipboard.writeText(text)
|
|
setCopied(true)
|
|
setTimeout(() => setCopied(false), 2000)
|
|
}
|
|
|
|
return (
|
|
<FumadocsCodeBlock
|
|
{...props}
|
|
className={cn('!border !border-fd-border !shadow-none', props.className)}
|
|
Actions={({ className }) => (
|
|
<div className={cn('empty:hidden', className)}>
|
|
<button
|
|
type='button'
|
|
aria-label={copied ? 'Copied Text' : 'Copy Text'}
|
|
onClick={(e) => {
|
|
const pre = (e.currentTarget as HTMLElement).closest('figure')?.querySelector('pre')
|
|
if (pre) handleCopy(pre.textContent || '')
|
|
}}
|
|
className='cursor-pointer rounded-md p-2 text-muted-foreground transition-colors hover:text-foreground'
|
|
>
|
|
<span className='flex items-center justify-center'>
|
|
{copied ? (
|
|
<Check size={16} className='text-green-600 dark:text-green-400' />
|
|
) : (
|
|
<Copy size={16} className='text-muted-foreground' />
|
|
)}
|
|
</span>
|
|
</button>
|
|
</div>
|
|
)}
|
|
/>
|
|
)
|
|
}
|