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 Block
object. In this callout, there are some examples for appending blocks to block. examples for appending blocks to page are described under the callout.
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.
block = BookmarkBlock.new "<https://www.google.com>", caption: "Google"
block = BreadcrumbBlock.new
block = BulletedListItemBlock.new "Bullet list item", color: "green", sub_blocks: sub_block
Bullet list item
with children
block = CalloutBlock.new "Emoji callout", emoji: "✅", color: "blue", sub_blocks: sub_block
<aside> ✅ Emoji callout
with children
</aside>
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>
block = CodeBlock.new "% ls -l", caption: "List files", language: "shell"
% ls -l
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>
block = DividerBlock.new
block = EmbedBlock.new "<https://twitter.com/hkob/status/1507972453095833601>", caption: "NotionRubyMapping開発記録(21)"
NotionRubyMapping開発記録(21)
block = EquationBlock.new "x = \\\\frac{-b\\\\pm\\\\sqrt{b^2-4ac}}{2a}"
$$ x = \frac{-b\pm\sqrt{b^2-4ac}}{2a} $$
block = FileBlock.new "<https://img.icons8.com/ios-filled/250/000000/mac-os.png>", caption: "macOS icon"
macOS icon
block = Heading1Block.new "Heading 1", color: "orange_background"
block = Heading2Block.new "Heading 2", color: "blue_background"
block = Heading3Block.new "Heading 3", color: "gray_background"
Notion logo
</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.
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.