-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unknown Block Type "code block" #49
Comments
Any luck? |
Does the key in e.g.,
|
In my case, the error was because I defined the // CodeBlock.tsx
import Refractor from "react-refractor";
import js from "refractor/lang/javascript";
import ts from "refractor/lang/typescript";
Refractor.registerLanguage(js);
Refractor.registerLanguage(ts);
type codeTypes = {
value: {
code: string;
language: string;
filename?: string;
};
};
export default function CodeBlock({ value }: codeTypes) {
return (
<div>
<p>{value.filename}</p>
<Refractor
language={value.language}
value={value.code}
/>
</div>
);
} And then in the PortableText component // CustomPortableTextComponent.tsx
import CodeBlock from "./codeBlock"
import { PortableTextComponents } from "@portabletext/react";
export const CustomPortableTextComponent: PortableTextComponents = {
types: {
code: CodeBlock,
},
} |
How would I go about applying styling to this? |
Just download any app/
├── global.css
└── styles/
└── prism-dracula.css And then import it into your @import "./styles/prism-dracula.css";
... |
I get this error whenever I try to render the formatted code in my user component (next.js 13)
[@portabletext/react] Unknown block type "Code block", specify a component for it in the
components.typesprop
I don't know if I am doing something wrong, here is my RichTextComponent.ts file
Although the formatted code shows in my sanity studio.
Can anyone help out.
Thanks.
The text was updated successfully, but these errors were encountered: