Class: Jekyll::NotionImport::Database
- Inherits:
-
Object
- Object
- Jekyll::NotionImport::Database
- Defined in:
- lib/jekyll-notion-import/database.rb
Instance Method Summary collapse
- #collection_name ⇒ Object
- #data_name ⇒ Object
-
#fetch ⇒ Object
Returns an empty array or a NotionToMd:Page array.
- #filter ⇒ Object
- #id ⇒ Object
-
#initialize(config: {}) ⇒ Database
constructor
A new instance of Database.
- #sorts ⇒ Object
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_name ⇒ Object
35 36 37 |
# File 'lib/jekyll-notion-import/database.rb', line 35 def collection_name config["collection"] || "posts" end |
#data_name ⇒ Object
39 40 41 |
# File 'lib/jekyll-notion-import/database.rb', line 39 def data_name config["data"] end |
#fetch ⇒ Object
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 |
#filter ⇒ Object
24 25 26 |
# File 'lib/jekyll-notion-import/database.rb', line 24 def filter config["filter"] end |
#id ⇒ Object
11 12 13 |
# File 'lib/jekyll-notion-import/database.rb', line 11 def id config["id"] end |
#sorts ⇒ Object
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 |