Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created February 27, 2022 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunosabot/983ed6698517b94caff8f884a3f56dd5 to your computer and use it in GitHub Desktop.
Save brunosabot/983ed6698517b94caff8f884a3f56dd5 to your computer and use it in GitHub Desktop.
import React from "react";
import classes from "./Post.module.css";
import Prism from "react-syntax-highlighter/dist/cjs/prism";
interface IGistProps {
lang: string;
file?: string;
code: string;
}
const Gist: React.FC<IGistProps> = ({ lang, file, code }) => {
return (
<>
{file ? (
<div className={classes["blog-post-gist-filename"]}>{file}</div>
) : null}
<Prism
language={lang === "" ? "text" : lang}
showLineNumbers={lang !== "text"}
wrapLines
wrapLongLines={lang === "text"}
>
{code}
</Prism>
</>
);
};
export default Gist;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment