File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -33,20 +33,20 @@ export default {
3333 } ,
3434 } ,
3535 async run ( { $ } ) {
36- let markdownContent ;
37- if ( this . retrieveMarkdown ) {
38- markdownContent = await this . notion . getPageAsMarkdown ( this . blockId ) ;
39- }
40-
4136 const { retrieveChildren } = this ;
4237 const subpagesOnly = retrieveChildren === "Sub-Pages Only" ;
43-
44- const block = await this . notion . retrieveBlock ( this . blockId ) ;
4538 const shouldRetrieveChildren = [
4639 true ,
4740 "All Children" ,
4841 "Sub-Pages Only" ,
4942 ] . includes ( retrieveChildren ) ;
43+
44+ let markdownContent ;
45+ if ( this . retrieveMarkdown ) {
46+ markdownContent = await this . notion . getPageAsMarkdown ( this . blockId , shouldRetrieveChildren ) ;
47+ }
48+
49+ const block = await this . notion . retrieveBlock ( this . blockId ) ;
5050 if ( shouldRetrieveChildren ) {
5151 block . children = await this . notion . retrieveBlockChildren ( block , subpagesOnly ) ;
5252 }
Original file line number Diff line number Diff line change @@ -357,14 +357,20 @@ export default {
357357
358358 return response . results ;
359359 } ,
360- async getPageAsMarkdown ( pageId ) {
361- const notionClient = this . _getNotionClient ( ) ;
360+ async getPageAsMarkdown ( pageId , shouldRetrieveChildren ) {
361+ const notion = this . _getNotionClient ( ) ;
362362
363363 const n2m = new NotionToMarkdown ( {
364- notionClient,
364+ notionClient : notion ,
365+ config : {
366+ separateChildPage : true ,
367+ } ,
365368 } ) ;
366369 const blocks = await n2m . pageToMarkdown ( pageId ) ;
367- return n2m . toMarkdownString ( blocks ) . parent ;
370+ const output = n2m . toMarkdownString ( blocks ) ;
371+ return shouldRetrieveChildren
372+ ? output
373+ : output . parent ;
368374 } ,
369375 } ,
370376} ;
You can’t perform that action at this time.
0 commit comments