Class: Jekyll::NotionImport::Import

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Import

Returns a new instance of Import.



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

def initialize(config:)
  @config = config["notion"] || {}
end

Class Method Details

.performObject



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

def self.perform(...)
  new(...).tap(&:perform)
end

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jekyll-notion-import/import.rb', line 14

def perform
  return unless notion_token? && config?

  config["databases"].each do |database_config|
    database = Database.new(config: database_config)

    database.fetch.each do |page|
      Post.new(
        collection_name: database.collection_name,
        page:,
        default_front_matter: Hash(database_config["default_front_matter"])
      ).import
    end
  end
end