Class: JekyllNotion::NotionPage

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-notion/notion_page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page:, layout:) ⇒ NotionPage

Returns a new instance of NotionPage.



7
8
9
10
# File 'lib/jekyll-notion/notion_page.rb', line 7

def initialize(page:, layout:)
  @page = page
  @layout = layout
end

Instance Attribute Details

#layoutObject (readonly)

Returns the value of attribute layout.



5
6
7
# File 'lib/jekyll-notion/notion_page.rb', line 5

def layout
  @layout
end

#pageObject (readonly)

Returns the value of attribute page.



5
6
7
# File 'lib/jekyll-notion/notion_page.rb', line 5

def page
  @page
end

Instance Method Details

#coverObject



18
19
20
# File 'lib/jekyll-notion/notion_page.rb', line 18

def cover
  page.dig(:cover, :external, :url)
end

#created_dateObject



30
31
32
# File 'lib/jekyll-notion/notion_page.rb', line 30

def created_date
  created_datetime.to_date
end

#created_datetimeObject



34
35
36
# File 'lib/jekyll-notion/notion_page.rb', line 34

def created_datetime
  DateTime.parse(page["created_time"])
end

#iconObject



22
23
24
# File 'lib/jekyll-notion/notion_page.rb', line 22

def icon
  page.dig(:icon, :emoji)
end

#idObject



26
27
28
# File 'lib/jekyll-notion/notion_page.rb', line 26

def id
  page[:id]
end

#titleObject



12
13
14
15
16
# File 'lib/jekyll-notion/notion_page.rb', line 12

def title
  page.dig(:properties, :Name, :title).inject("") do |acc, slug|
    acc + slug[:plain_text]
  end
end

#updated_dateObject



38
39
40
# File 'lib/jekyll-notion/notion_page.rb', line 38

def updated_date
  updated_datetime.to_date
end

#updated_datetimeObject



42
43
44
# File 'lib/jekyll-notion/notion_page.rb', line 42

def updated_datetime
  DateTime.parse(page["last_edited_time"])
end

#urlObject



46
47
48
# File 'lib/jekyll-notion/notion_page.rb', line 46

def url
  page[:url]
end