Class: JekyllNotion::Generator

Inherits:
Jekyll::Generator
  • Object
show all
Defined in:
lib/jekyll-notion/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_dbObject (readonly)

Returns the value of attribute current_db.



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

def current_db
  @current_db
end

#current_pageObject (readonly)

Returns the value of attribute current_page.



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

def current_page
  @current_page
end

Instance Method Details

#collectionsObject



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

def collections
  @collections ||= {}
end

#config_databasesObject



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

def config_databases
  config["databases"] || [config["database"]]
end

#config_pagesObject



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

def config_pages
  config["pages"] || [config["page"]]
end

#dataObject



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

def data
  @data ||= {}
end

#generate(site) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jekyll-notion/generator.rb', line 7

def generate(site)
  @site = site

  return unless notion_token? && config?

  if fetch_on_watch? || cache_empty?
    read_notion_databases
    read_notion_pages
  else
    collections.each_pair { |key, val| @site.collections[key] = val }
    data.each_pair { |key, val| @site.data[key] = val }
    pages.each { |page| @site.pages << page }
  end
end

#pagesObject



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

def pages
  @pages ||= []
end