Manuals Notion Ruby Mapping Public API Reference NotionRubyMapping idea note
Examples Append block children sample

<aside> 💡 This page was created for testing NorionRubyMapping. I thought this page was best suited to explain the append_child_block API, so I am presenting it as a use case.

</aside>

<aside> ℹ️ ↑ Table of Contents

</aside>

<aside> 💡 append_block_chidren can be used to Page and Blockobject. In this callout, there are some examples for appending blocks to block. examples for appending blocks to page are described under the callout.

Append block children for Block

Here is a paragraph block for test of append block children for a block. This block is obtained as org_block as follows. Moreover, a test sub_block object is generated by Block.new.paragraph method.

org_block = Block.find "82314687163e41baaf300a8a2bec57c2" # This callout block's id
sub_block = ParagraphBlock.new "with children"

block = XXXBlock.new(some arguments....) # create a block object
org_block.append_block_children block # call append_block_children API

From here, the code to create a block and its products are shown side by side. The each mention link of Block after “→” is the link to the method reference.


1. BookmarkBlock

block = BookmarkBlock.new "<https://www.google.com>", caption: "Google"

Google

↑ Table of Contents


2. BreadcrumbBlock

block = BreadcrumbBlock.new

↑ Table of Contents


3. BulletedListItemBlock

block = BulletedListItemBlock.new "Bullet list item", color: "green", sub_blocks: sub_block

↑ Table of Contents


4. CalloutBlock (emoji)

block = CalloutBlock.new "Emoji callout", emoji: "✅", color: "blue", sub_blocks: sub_block

<aside> ✅ Emoji callout

with children

</aside>

↑ Table of Contents


5. CalloutBlock (file_url)

block = CalloutBlock.new "Url callout", file_url: "<https://img.icons8.com/ios-filled/250/000000/mac-os.png>", sub_blocks: sub_block

<aside> <img src="https://img.icons8.com/ios-filled/250/000000/mac-os.png" alt="https://img.icons8.com/ios-filled/250/000000/mac-os.png" width="40px" /> Url callout

with children

</aside>

↑ Table of Contents


6. CodeBlock

block = CodeBlock.new "% ls -l", caption: "List files", language: "shell"
% ls -l

↑ Table of Contents


7. ColumnListBlock

block = ColumnListBlock.new [
  CalloutBlock.new("Emoji callout", emoji: "✅"),
  CalloutBlock.new("Url callout", file_url: "<https://img.icons8.com/ios-filled/250/000000/mac-os.png>"),
]

<aside> ✅ Emoji callout

</aside>

<aside> <img src="https://img.icons8.com/ios-filled/250/000000/mac-os.png" alt="https://img.icons8.com/ios-filled/250/000000/mac-os.png" width="40px" /> Url callout

</aside>

↑ Table of Contents


8. DividerBlock

block = DividerBlock.new

↑ Table of Contents

9. EmbedBlock

block = EmbedBlock.new "<https://twitter.com/hkob/status/1507972453095833601>", caption: "NotionRubyMapping開発記録(21)"

NotionRubyMapping開発記録(21)

NotionRubyMapping開発記録(21)

↑ Table of Contents


10. EquationBlock

block = EquationBlock.new "x = \\\\frac{-b\\\\pm\\\\sqrt{b^2-4ac}}{2a}"

$$ x = \frac{-b\pm\sqrt{b^2-4ac}}{2a} $$

↑ Table of Contents


11. FileBlock

block = FileBlock.new "<https://img.icons8.com/ios-filled/250/000000/mac-os.png>", caption: "macOS icon"

macOS icon

macOS icon

↑ Table of Contents


12. Heading1Block

block = Heading1Block.new "Heading 1", color: "orange_background"

Heading 1

↑ Table of Contents


13. Heading2Block

block = Heading2Block.new "Heading 2", color: "blue_background"

Heading 2

↑ Table of Contents


14. Heading3Block

block = Heading3Block.new "Heading 3", color: "gray_background"

Heading 3

↑ Table of Contents


Notion logo

Notion logo

↑ Table of Contents


notion_ruby_mapping_test_data

↑ Table of Contents


New database title(Added)

↑ Table of Contents


  1. Numbered list item

↑ Table of Contents

</aside>

Here is a paragraph block for test of append block children for a block. This block is obtained as org_block as follows. Moreover, a test sub_block object is generated by Block.new.paragraph method.

Append block children for Page

Here is a page for test of append block children for a page. This page is obtained as org_page as follows. Moreover, a test sub_block object is generated by Block.new.paragraph method

org_page = Page.find "3867910a437340be931cf7f2c06443c6" # This page's id
sub_block = Block.new.paragraph "with children"

From here, the code to create and its products are shown side by side. The each mention link of Block after “→” is the link to the method reference.


Google

↑ Table of Contents


↑ Table of Contents