-
Notifications
You must be signed in to change notification settings - Fork 16
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
How to use NODE_HEADING? #36
Comments
To return a custom component for level 2 headings you need this: [NODE_HEADING]: (children, { level }) => {
if (level === 2) {
return <H2>{children}</H2>;
} else {
const Heading = `h${level}`;
return <Heading>{children}</Heading>;
}
} This library renders the data it gets from Storyblok as is, it doesn't have any built in functionality to remove elements. That said, it also doesn't add any spaces where there are none. What you probably want to do is style those |
Regarding your second question, you could also try this: [NODE_LI]: (children) => {
if (Children.count(children) === 1) {
const child = Children.toArray(children)[0];
if (child.type === "p") {
return <li>{child.props.children}</li>;
}
}
return <li>{children}</li>;
}, (code above is untested) |
Hello, I tried this, but there was no transformation occurring... the transform for the paragraph and code nodes is working... am I doing something absurd?
|
Hmm, that code looks good to me. Is that heading resolver executed at all? |
The headings aren't changed, the other elements are... |
Any ideas @claus I wasn't able to spot the issue. |
As i said, your code looks good, and it would be helpful if you could find out if that |
[NODE_HEADING]: (children, { attrs: { "level": 2, }}) => <H2>{children}</H2>,
I am trying this, but it doesn't seem to work, and I found the example a little terse... could you clarify for me (the H2 is a new custom component).
Also, how to remove the
<p>
tag which is inside a<li>
, as<li><p></p></li>
adds an extra space and looks rather awful when rendered!The text was updated successfully, but these errors were encountered: