@@ -2,6 +2,7 @@ import * as React from "react";
22import { DecorationType , BlockType , ContentValueType } from "./types" ;
33import Asset from "./components/asset" ;
44import Code from "./components/code" ;
5+ import { classNames , getTextContent } from "./utils" ;
56
67export const renderChildText = ( properties : DecorationType [ ] ) => {
78 return properties . map ( ( [ text , decorations ] , i ) => {
@@ -171,7 +172,11 @@ export const Block: React.FC<Block> = props => {
171172 case "callout" :
172173 return (
173174 < div
174- className = { `notion-callout notion-${ blockValue . format . block_color } _co` }
175+ className = { classNames (
176+ "notion-callout" ,
177+ blockValue . format . block_color &&
178+ `notion-${ blockValue . format . block_color } _co`
179+ ) }
175180 >
176181 < div > { blockValue . format . page_icon } </ div >
177182 < div className = "notion-callout-text" >
@@ -185,7 +190,11 @@ export const Block: React.FC<Block> = props => {
185190 < a
186191 target = "_blank"
187192 rel = "noopener noreferrer"
188- className = "notion-bookmark"
193+ className = { classNames (
194+ "notion-bookmark" ,
195+ blockValue . format . block_color &&
196+ `notion-${ blockValue . format . block_color } `
197+ ) }
189198 href = { blockValue . properties . link [ 0 ] [ 0 ] }
190199 >
191200 < div >
@@ -196,12 +205,18 @@ export const Block: React.FC<Block> = props => {
196205 { renderChildText ( blockValue . properties . description ) }
197206 </ div >
198207 < div className = "notion-bookmark-link" >
199- < img src = { blockValue . format . bookmark_icon } />
208+ < img
209+ src = { blockValue . format . bookmark_icon }
210+ alt = { getTextContent ( blockValue . properties . title ) }
211+ />
200212 < div > { renderChildText ( blockValue . properties . link ) } </ div >
201213 </ div >
202214 </ div >
203- < div >
204- < img src = { blockValue . format . bookmark_cover } />
215+ < div className = "notion-bookmark-image" >
216+ < img
217+ src = { blockValue . format . bookmark_cover }
218+ alt = { getTextContent ( blockValue . properties . title ) }
219+ />
205220 </ div >
206221 </ a >
207222 </ div >
0 commit comments