Skip to content

Commit 2c8f4be

Browse files
author
Sergei Orlov
committed
🐛 Add displaying nested blocks for all supported types
1 parent f2475ca commit 2c8f4be

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/transformers/get-page-md.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exports.getNotionPageMD = (page) =>
1515
}
1616

1717
if (block.type == "paragraph") {
18-
return acc.concat(blockToString(block.paragraph.text)).concat(`\n\n`)
18+
return acc.concat(blockToString(block.paragraph.text)).concat(EOL_MD).concat(childBlocksString)
1919
}
2020

2121
if (block.type.startsWith("heading_")) {
@@ -26,21 +26,31 @@ exports.getNotionPageMD = (page) =>
2626
.concat(" ")
2727
.concat(blockToString(block[block.type].text))
2828
.concat(EOL_MD)
29+
.concat(childBlocksString)
2930
}
3031

3132
if (block.type == "to_do") {
3233
return acc
3334
.concat(`- [${block.to_do.checked ? "x" : " "}] `)
3435
.concat(blockToString(block.to_do.text))
3536
.concat(EOL_MD)
37+
.concat(childBlocksString)
3638
}
3739

3840
if (block.type == "bulleted_list_item") {
39-
return acc.concat("* ").concat(blockToString(block.bulleted_list_item.text)).concat(EOL_MD)
41+
return acc
42+
.concat("* ")
43+
.concat(blockToString(block.bulleted_list_item.text))
44+
.concat(EOL_MD)
45+
.concat(childBlocksString)
4046
}
4147

4248
if (block.type == "numbered_list_item") {
43-
return acc.concat("1. ").concat(blockToString(block.numbered_list_item.text)).concat(EOL_MD)
49+
return acc
50+
.concat("1. ")
51+
.concat(blockToString(block.numbered_list_item.text))
52+
.concat(EOL_MD)
53+
.concat(childBlocksString)
4454
}
4555

4656
if (block.type == "toggle") {
@@ -53,7 +63,10 @@ exports.getNotionPageMD = (page) =>
5363
}
5464

5565
if (block.type == "unsupported") {
56-
return acc.concat(`<!-- This block is not supported by Notion API yet. -->`).concat(EOL_MD)
66+
return acc
67+
.concat(`<!-- This block is not supported by Notion API yet. -->`)
68+
.concat(EOL_MD)
69+
.concat(childBlocksString)
5770
}
5871

5972
return acc

0 commit comments

Comments
 (0)