File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ export class BlockRenderer {
68
68
private readonly richText : RichTextRenderer
69
69
) { }
70
70
71
- async renderBlockLine ( block : Block , assets : AssetWriter ) : Promise < string > {
71
+ async renderBlock ( block : Block , assets : AssetWriter ) : Promise < string > {
72
72
switch ( block . type ) {
73
73
case "paragraph" :
74
74
return this . richText . renderMarkdown ( block . paragraph . text ) ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export class RecursiveBodyRenderer {
34
34
}
35
35
36
36
const heading = `# ${ props . values [ "title" ] } \n\n` ;
37
-
37
+
38
38
return heading + body ;
39
39
}
40
40
@@ -43,8 +43,8 @@ export class RecursiveBodyRenderer {
43
43
indent : string ,
44
44
assets : AssetWriter
45
45
) : Promise < string > {
46
- const parentLine =
47
- indent + ( await this . blockRenderer . renderBlockLine ( block , assets ) ) ;
46
+ const parentBlock = await this . blockRenderer . renderBlock ( block , assets ) ;
47
+ const parentLines = this . indent ( parentBlock , indent ) ;
48
48
49
49
// due to the way the Notion API is built, we need to recurisvely retrieve child
50
50
// blocks, see https://developers.notion.com/reference/retrieve-a-block
@@ -59,6 +59,13 @@ export class RecursiveBodyRenderer {
59
59
) ;
60
60
const childLines = await Promise . all ( renderChilds ) ;
61
61
62
- return [ parentLine , ...childLines ] . join ( "\n\n" ) ;
62
+ return [ parentLines , ...childLines ] . join ( "\n\n" ) ;
63
+ }
64
+
65
+ private indent ( content : string , indent : string ) {
66
+ return content
67
+ . split ( "\n" )
68
+ . map ( ( x ) => indent + x )
69
+ . join ( "\n" ) ;
63
70
}
64
71
}
You can’t perform that action at this time.
0 commit comments