Class: JekyllNotion::PageGenerator

Inherits:
AbstractGenerator show all
Defined in:
lib/jekyll-notion/generators/page_generator.rb

Instance Method Summary collapse

Methods inherited from AbstractGenerator

#initialize, #resource_id

Constructor Details

This class inherits a constructor from JekyllNotion::AbstractGenerator

Instance Method Details

#generateObject



5
6
7
8
9
10
11
12
13
# File 'lib/jekyll-notion/generators/page_generator.rb', line 5

def generate
  notion_page = @notion_resource.fetch
  unless notion_page.nil?
    page = make_page(notion_page)
    @site.pages << page
    log_page(notion_page)
    @plugin.pages << page
  end
end

#log_page(notion_page) ⇒ Object



20
21
22
23
24
# File 'lib/jekyll-notion/generators/page_generator.rb', line 20

def log_page(notion_page)
  Jekyll.logger.info("Jekyll Notion:", "Page => #{notion_page.title}")
  Jekyll.logger.info("", "URL => #{@site.pages.last.url}")
  Jekyll.logger.debug("", "Props => #{notion_page.props.keys.inspect}")
end

#make_mdObject



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

def make_md
  NotionToMd::Converter.new(:page_id => @notion_resource.id).convert(:frontmatter => true)
end

#make_page(notion_page) ⇒ Object



15
16
17
18
# File 'lib/jekyll-notion/generators/page_generator.rb', line 15

def make_page(notion_page)
  JekyllNotion::PageWithoutAFile.new(@site, @site.source, "", "#{notion_page.title}.md",
                                     make_md)
end