Class: Florby::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/florby/builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject



12
13
14
# File 'lib/florby/builder.rb', line 12

def self.run
  new.run
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/florby/builder.rb', line 16

def run
  remove_old_files

  @config = Florby::Config.new
  if File.exist?(File.join(Dir.pwd, 'config.rb'))
    @config.load_file('config.rb')
  end

  copy_files

  collection = Collection.new
  Plugins::WikiLinkReplacer.new(collection: collection).replace!

  collection.all_pages.each do |page|
    html = Renderer.new(page: page, collection: collection).render
    write_html(page.permalink, html)
    page.aliases.each do |alias_path|
      write_html(alias_path, alias_html(page.permalink))
    end
  end

  SitemapGenerator::Sitemap.default_host = @config.fetch('host')
  SitemapGenerator::Sitemap.public_path = '_build'
  SitemapGenerator::Sitemap.compress = false
  SitemapGenerator::Sitemap.create do
    collection.all_pages.each do |page|
      add page.permalink, lastmod: page.updated
    end
  end
end