@@ -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,14 +172,55 @@ 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" >
178183 { renderChildText ( blockValue . properties . title ) }
179184 </ div >
180185 </ div >
181186 ) ;
187+ case "bookmark" :
188+ return (
189+ < div className = "notion-row" >
190+ < a
191+ target = "_blank"
192+ rel = "noopener noreferrer"
193+ className = { classNames (
194+ "notion-bookmark" ,
195+ blockValue . format . block_color &&
196+ `notion-${ blockValue . format . block_color } `
197+ ) }
198+ href = { blockValue . properties . link [ 0 ] [ 0 ] }
199+ >
200+ < div >
201+ < div className = "notion-bookmark-title" >
202+ { renderChildText ( blockValue . properties . title ) }
203+ </ div >
204+ < div className = "notion-bookmark-description" >
205+ { renderChildText ( blockValue . properties . description ) }
206+ </ div >
207+ < div className = "notion-bookmark-link" >
208+ < img
209+ src = { blockValue . format . bookmark_icon }
210+ alt = { getTextContent ( blockValue . properties . title ) }
211+ />
212+ < div > { renderChildText ( blockValue . properties . link ) } </ div >
213+ </ div >
214+ </ div >
215+ < div className = "notion-bookmark-image" >
216+ < img
217+ src = { blockValue . format . bookmark_cover }
218+ alt = { getTextContent ( blockValue . properties . title ) }
219+ />
220+ </ div >
221+ </ a >
222+ </ div >
223+ ) ;
182224 default :
183225 if ( process . env . NODE_ENV !== "production" ) {
184226 console . log ( "Unsupported type " + block ?. value ?. type ) ;
0 commit comments