1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-21 05:01:16 -04:00

next-mdx-remote v4 (#737)

This commit is contained in:
2022-01-18 09:25:09 -05:00
committed by GitHub
parent 2ef5d06c38
commit a406010bd2
110 changed files with 1009 additions and 1490 deletions

View File

@@ -0,0 +1,28 @@
import CopyButton from "../CopyButton/CopyButton";
import type { ReactNode } from "react";
import styles from "./CodeBlock.module.css";
export type Props = {
className?: string;
children: ReactNode;
};
const CodeBlock = (props: Props) => {
if (props.className?.split(" ").includes("code-highlight")) {
// full multi-line code blocks with prism highlighting and copy-to-clipboard button
return (
<>
<div className={styles.code}>
<CopyButton source={props.children} />
<code {...props}>{props.children}</code>
</div>
</>
);
} else {
// inline code in paragraphs, headings, etc. (not highlighted)
return <code {...props}>{props.children}</code>;
}
};
export default CodeBlock;