Class: Jekyll::NotionImport::Database

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

Instance Method Summary collapse

Constructor Details

#initialize(config: {}) ⇒ Database

Returns a new instance of Database.



6
7
8
9
# File 'lib/jekyll-notion-import/database.rb', line 6

def initialize(config: {})
  @notion = Notion::Client.new
  @config = config
end

Instance Method Details

#collection_nameObject



35
36
37
# File 'lib/jekyll-notion-import/database.rb', line 35

def collection_name
  config["collection"] || "posts"
end

#data_nameObject



39
40
41
# File 'lib/jekyll-notion-import/database.rb', line 39

def data_name
  config["data"]
end

#fetchObject

Returns an empty array or a NotionToMd:Page array



16
17
18
19
20
21
22
# File 'lib/jekyll-notion-import/database.rb', line 16

def fetch
  return [] unless id?

  @fetch ||= notion.database_query(query)[:results].map do |page|
    page = NotionToMd::Page.new(:page => page, :blocks => build_blocks(page.id))
  end
end

#filterObject



24
25
26
# File 'lib/jekyll-notion-import/database.rb', line 24

def filter
  config["filter"]
end

#idObject



11
12
13
# File 'lib/jekyll-notion-import/database.rb', line 11

def id
  config["id"]
end

#sortsObject



28
29
30
31
32
33
# File 'lib/jekyll-notion-import/database.rb', line 28

def sorts
  if config["sort"]
    Jekyll.logger.warn("Jekyll Notion:", "sort property is deprecated, use sorts instead")
  end
  config["sorts"]
end