Compare commits

..

No commits in common. "712887d86e75b249ee32dfb87d6001ecba6a9f7b" and "172eb25fe86026b29a184116e7773e5c0706daf6" have entirely different histories.

2 changed files with 8 additions and 6 deletions

View file

@ -123,21 +123,23 @@ const customPortableTextComponents: PortableTextComponents = {
); );
}, },
code: ({ value }) => { code: ({ value }) => {
const language = value.language || "none"; const language = value.language;
const grammar = Prism.languages[language]; const grammar = Prism.languages[language];
if (!grammar) { if (language && !grammar) {
console.error(`No grammar found for language: "${language}"`); console.error(`No grammar found for language: "${language}"`);
} }
return ( return (
<div className="relative my-8"> <div className="relative my-8">
<pre <pre
className={`language-${language} p-4 rounded-md overflow-x-auto text-sm`} className={`${language ? "language-" + language + " " : ""}p-4 rounded-md overflow-x-auto text-sm`}
> >
<code className={`language-${language}`}>{value.code}</code> <code className={language ? "language-" + language : ""}>
{value.code}
</code>
</pre> </pre>
{language == "none" ? "" : <PrismLoader />} {language ? <PrismLoader /> : ""}
<CopyButton code={value.code} /> <CopyButton code={value.code} />
</div> </div>
); );

View file

@ -20,7 +20,7 @@ export default function CopyButton({ code }: { code: string }) {
return ( return (
<Button <Button
onClick={copyCode} onClick={copyCode}
className="absolute top-2 right-2 bg-accent hover:bg-muted p-2 rounded" className="absolute top-2 right-2 bg-accent hover:bg-muted text-white p-2 rounded"
size={"icon"} size={"icon"}
> >
{copied ? <Check className="w-5 h-5" /> : <Copy className="w-5 h-5" />} {copied ? <Check className="w-5 h-5" /> : <Copy className="w-5 h-5" />}