initial commit
This commit is contained in:
commit
e2466b202a
50 changed files with 4356 additions and 0 deletions
29
islands/Code.tsx
Normal file
29
islands/Code.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Copyright (c) 2025 favewa
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { ComponentChildren } from "preact";
|
||||
|
||||
interface CodeProps {
|
||||
children: ComponentChildren;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export default function Code({ children, ...props }: CodeProps) {
|
||||
const handleClick = () => {
|
||||
const element = (children as any)?.props?.children[0];
|
||||
element && navigator.clipboard.writeText(element);
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
class="inline-code"
|
||||
onClick={handleClick}
|
||||
title="Click to copy"
|
||||
{...props}
|
||||
>
|
||||
<span>{children}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue