fix: make code blocks with no language consistent with code block with a language set
This commit is contained in:
parent
172eb25fe8
commit
cb4534e3b5
1 changed files with 5 additions and 7 deletions
|
@ -123,23 +123,21 @@ const customPortableTextComponents: PortableTextComponents = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
code: ({ value }) => {
|
code: ({ value }) => {
|
||||||
const language = value.language;
|
const language = value.language || "none";
|
||||||
const grammar = Prism.languages[language];
|
const grammar = Prism.languages[language];
|
||||||
|
|
||||||
if (language && !grammar) {
|
if (!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-" + language + " " : ""}p-4 rounded-md overflow-x-auto text-sm`}
|
className={`language-${language} p-4 rounded-md overflow-x-auto text-sm`}
|
||||||
>
|
>
|
||||||
<code className={language ? "language-" + language : ""}>
|
<code className={`language-${language}`}>{value.code}</code>
|
||||||
{value.code}
|
|
||||||
</code>
|
|
||||||
</pre>
|
</pre>
|
||||||
{language ? <PrismLoader /> : ""}
|
{language == "none" ? "" : <PrismLoader />}
|
||||||
<CopyButton code={value.code} />
|
<CopyButton code={value.code} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue