Unverified Commit bd1cf627 authored by Mark Zhao's avatar Mark Zhao Committed by GitHub

feat: enable iframe rendering in markdown code block (#2799)

* enable iframe rendering in code block

* fix eslint issue
parent 196facfa
...@@ -15,6 +15,16 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => { ...@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment