Sha256: 4ea149bcf7d36f6db760b45adff73bf47b0487ee0b1cabdcb7120c2df58f9d77
Contents?: true
Size: 796 Bytes
Versions: 2
Compression:
Stored size: 796 Bytes
Contents
require "jekyll/pages/ebook" module Jekyll Jekyll::Hooks.register :pages, :post_write do |page| if page.is_a? Jekyll::EbookPage default_setting = { "formats" => ["pdf"] } configs = Jekyll.configuration() books_config = configs["books_settings"] || {} ebook_config = default_setting.merge(books_config["ebook"] || {}) if ebook_config["enabled"] input = page.destination("") site = page.site dir = site.in_dest_dir(page.dir) ebook_config["formats"].each do |format| output = File.join(dir, "#{page.data["name"]}.#{format}") system "ebook-convert #{input} #{output} --title=#{page.data['book']['title']} --authors=#{configs['title']} --level1-toc=//h:h1" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jekyll-books-0.3.1 | lib/jekyll/hooks/ebook.rb |
jekyll-books-0.3.0 | lib/jekyll/hooks/ebook.rb |