Class: NotionToHtml::Page

Inherits:
Object
  • Object
show all
Includes:
Renderers
Defined in:
lib/notion_to_html/page.rb

Constant Summary

Constants included from Renderers

Renderers::DEFAULT_CSS_CLASSES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Renderers

#annotation_to_css_class, #render_bulleted_list_item, #render_callout, #render_code, #render_date, #render_heading_1, #render_heading_2, #render_heading_3, #render_image, #render_numbered_list_item, #render_paragraph, #render_quote, #render_table_of_contents, #render_video, #text_renderer

Constructor Details

#initialize(base_page, base_blocks) ⇒ Page

Initializes a new Page object.

Parameters:

  • base_page (BasePage)

    The metadata of the page.

  • base_blocks (Array<BaseBlock>)

    The blocks of the page.



23
24
25
26
# File 'lib/notion_to_html/page.rb', line 23

def initialize(base_page, base_blocks)
  @metadata = base_page
  @blocks = base_blocks
end

Instance Attribute Details

#blocksArray<BaseBlock> (readonly)

Returns The blocks of the page, representing the content sections.

Returns:

  • (Array<BaseBlock>)

    The blocks of the page, representing the content sections.



13
14
15
# File 'lib/notion_to_html/page.rb', line 13

def blocks
  @blocks
end

#metadataBasePage (readonly)

Returns The metadata of the page, encapsulating details like title, description, and published date.

Returns:

  • (BasePage)

    The metadata of the page, encapsulating details like title, description, and published date.



11
12
13
# File 'lib/notion_to_html/page.rb', line 11

def 
  @metadata
end

Instance Method Details

#formatted_blocks(options = {}) ⇒ Array<String>

Formats and renders the blocks of the page.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options for rendering the blocks.

Returns:

  • (Array<String>)

    The rendered blocks as an array of HTML strings.



31
32
33
# File 'lib/notion_to_html/page.rb', line 31

def formatted_blocks(options = {})
  @blocks.map { |block| block.render(options) }
end