|
|
@ -15,6 +15,16 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => {
|
|
|
|
const formatedLanguage = language.toLowerCase() || "plaintext";
|
|
|
|
const formatedLanguage = language.toLowerCase() || "plaintext";
|
|
|
|
let highlightedCode = hljs.highlightAuto(content).value;
|
|
|
|
let highlightedCode = hljs.highlightAuto(content).value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Users can set Markdown code blocks as 'iframe'
|
|
|
|
|
|
|
|
// to embed videos or external audio links from services like Apple Music or Spotify.
|
|
|
|
|
|
|
|
if (formatedLanguage === "iframe") {
|
|
|
|
|
|
|
|
const renderHTML = () => {
|
|
|
|
|
|
|
|
return { __html: content };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return <div className="mx-auto w-11/12 !my-4" dangerouslySetInnerHTML={renderHTML()} />;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const temp = hljs.highlight(content, {
|
|
|
|
const temp = hljs.highlight(content, {
|
|
|
|
language: formatedLanguage,
|
|
|
|
language: formatedLanguage,
|
|
|
|