Skip to content

Commit 9b95321

Browse files
timolinstobiaslins
andcommitted
Fix bug for multiple decorations
Co-authored-by: Tobias Lins <me@tobi.sh>
1 parent 213d102 commit 9b95321

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/block.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@ import Code from "./components/code";
55

66
export const renderChildText = (properties: DecorationType[]) => {
77
if (!properties) return null;
8-
return properties.map(([text, decorations], index) => {
8+
return properties.map(([text, decorations], i) => {
99
if (!decorations) {
1010
return text;
1111
}
1212

13-
return decorations.map(decorator => {
13+
return decorations.reduce((element, decorator) => {
1414
switch (decorator[0]) {
1515
case "h":
1616
return (
17-
<span key={index} className={`notion-${decorator[1]}`}>
18-
{text}
17+
<span key={i} className={`notion-${decorator[1]}`}>
18+
{element}
1919
</span>
2020
);
2121
case "c":
2222
return (
23-
<code key={index} className="notion-inline-code">
24-
{text}
23+
<code key={i} className="notion-inline-code">
24+
{element}
2525
</code>
2626
);
2727
case "b":
28-
return <b key={index}>{text}</b>;
28+
return <b key={i}>{element}</b>;
2929
case "i":
30-
return <em key={index}>{text}</em>;
30+
return <em key={i}>{element}</em>;
3131
case "s":
32-
return <s key={index}>{text}</s>;
32+
return <s key={i}>{element}</s>;
3333
case "a":
3434
return (
35-
<a className="notion-link" href={decorator[1]} key={index}>
36-
{text}
35+
<a className="notion-link" href={decorator[1]} key={i}>
36+
{element}
3737
</a>
3838
);
3939

4040
default:
41-
return <React.Fragment key={index}>text</React.Fragment>;
41+
return <React.Fragment key={i}>{element}</React.Fragment>;
4242
}
43-
});
43+
}, <>{text}</>);
4444
});
4545
};
4646

0 commit comments

Comments
 (0)