class NotionToMd::Converter
Attributes
page_id[R]
Public Class Methods
new(page_id:, token: nil)
click to toggle source
# File lib/notion_to_md/converter.rb, line 7 def initialize(page_id:, token: nil) @notion = Notion::Client.new(token: token || ENV['NOTION_TOKEN']) @page_id = page_id end
Public Instance Methods
convert(frontmatter: false)
click to toggle source
# File lib/notion_to_md/converter.rb, line 12 def convert(frontmatter: false) md_page = Page.new(page: page, blocks: page_blocks) <<~MD #{md_page.frontmatter if frontmatter} #{md_page.body} MD end
Private Instance Methods
page()
click to toggle source
# File lib/notion_to_md/converter.rb, line 22 def page @page ||= @notion.page(page_id: page_id) end
page_blocks()
click to toggle source
# File lib/notion_to_md/converter.rb, line 26 def page_blocks @page_blocks ||= @notion.block_children(block_id: page_id) end