<aside> 👉
Links (Block base class)
Notion Ruby Mapping Public API Reference
</aside>
LinkToPageBlockArgumentError
Raised if neither or both IDs are specified.self.new creates a LinkToPageBlock that links to a page or a full-page database. Specify exactly one of page_id or database_id. IDs and Notion URLs are accepted and stored as normalized IDs without hyphens.
block = LinkToPageBlock.new page_id: "c01166c6-13ae-45cb-b968-18b4ef2f5a77"
block.page_id
# => "c01166c613ae45cbb96818b4ef2f5a77"
block.block_json
# => {"type"=>"link_to_page", "object"=>"block", "link_to_page"=>{"type"=>"page_id", "page_id"=>"c01166c613ae45cbb96818b4ef2f5a77"}}
block = LinkToPageBlock.new database_id: "c7697137-d49f-49c2-bbcd-d6a665c4f921"
block.database_id
# => "c7697137d49f49c2bbcdd6a665c4f921"
database_id returns the normalized database ID when the block links to a database. It returns nil when the block links to a page.
block = LinkToPageBlock.new database_id: "c7697137-d49f-49c2-bbcd-d6a665c4f921"
block.database_id
# => "c7697137d49f49c2bbcdd6a665c4f921"
block.page_id
# => nil
page_id returns the normalized page ID when the block links to a page. It returns nil when the block links to a database.
block = LinkToPageBlock.new page_id: "c01166c6-13ae-45cb-b968-18b4ef2f5a77"
block.page_id
# => "c01166c613ae45cbb96818b4ef2f5a77"
block.database_id
# => nil
LinkToPageBlock supports links identified by page_id or database_id.comment_id is not supported, even though it appears in the official JavaScript SDK type definitions. Retrieving a link with an unsupported type raises ArgumentError.data_source_id is not supported. A database link identifies the database itself, not one of its data sources.link_to_page blocks, although the current Block object reference does not provide a dedicated section for this block type.