diff --git a/src/app/c/[...slug]/page.tsx b/src/app/c/[...slug]/page.tsx index d72f8d1..6650d5f 100644 --- a/src/app/c/[...slug]/page.tsx +++ b/src/app/c/[...slug]/page.tsx @@ -9,7 +9,8 @@ import rehypeRaw from "rehype-raw"; import rehypeHighlight from "rehype-highlight"; import { notFound } from "next/navigation"; import Link from "next/link"; -import CodeBlock from "$components/code-block"; +import CopyButton from "$components/copy-button"; +import { getText } from "@/app/lib/react"; type Params = { slug: string[] @@ -75,7 +76,10 @@ export default function Content({ params }: Props) { }, pre({ children, className }) { return ( - {children} +
+ +
{children}
+
) } }} diff --git a/src/app/components/code-block.tsx b/src/app/components/code-block.tsx deleted file mode 100644 index 5fcba8a..0000000 --- a/src/app/components/code-block.tsx +++ /dev/null @@ -1,40 +0,0 @@ -"use client" -import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons" -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" -import { ReactNode, useState } from "react" - -type Props = { - className?: string - children?: ReactNode -} - -const getText = (node: any) => { - const props = node.props - if (!props) { - return node - } - const c = props.children - return typeof c === "string" ? c : c.map(getText).join("") -} - -const CodeBlock = ({ className, children }: Props) => { - const [visible, setVisible] = useState("invisible") - return ( -
- -
{children}
-
- ) -} - -export default CodeBlock; diff --git a/src/app/components/copy-button.tsx b/src/app/components/copy-button.tsx new file mode 100644 index 0000000..e1c681e --- /dev/null +++ b/src/app/components/copy-button.tsx @@ -0,0 +1,27 @@ +"use client" +import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons" +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" +import { useState } from "react" + +type Props = { + text: string +} + +const CopyButton = ({ text }: Props) => { + const [visible, setVisible] = useState("invisible") + return ( + + ) +} + +export default CopyButton; diff --git a/src/app/components/links.tsx b/src/app/components/links.tsx index d781ee9..c3834d4 100644 --- a/src/app/components/links.tsx +++ b/src/app/components/links.tsx @@ -6,10 +6,10 @@ const Links = () =>
- + - +
diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index 77def2d..bfd3c70 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -6,7 +6,7 @@ const mailto = `mailto:${email}` const Contact = () =>
- +
diff --git a/src/app/globals.css b/src/app/globals.css index da968af..ceb3c52 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -11,7 +11,11 @@ main { } svg { - @apply w-14 h-14 text-amber-100 hover:text-cyan-500 + @apply hover:text-cyan-500 +} + +.svg-link { + @apply w-14 h-14 } .btn { diff --git a/src/app/lib/react.ts b/src/app/lib/react.ts new file mode 100644 index 0000000..606622f --- /dev/null +++ b/src/app/lib/react.ts @@ -0,0 +1,10 @@ +import { ReactNode } from "react" + +export const getText = (node: ReactNode | any) => { + const props = node.props + if (!props) { + return node + } + const c = props.children + return typeof c === "string" ? c : c.map(getText).join("") +}