aboutsummaryrefslogtreecommitdiff
path: root/_plugins/generate-favicon.rb
blob: ee443a3ba1ceb0c66ff9b714824c27d53c674d1d (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Jekyll
  class FaviconGenerator < Generator
    safe true
    priority :high

    SIZE = 420

    def generate(site)
      svg = 'static/favicon.svg'
      png = 'static/favicon.png'
      unless File.exist? png then
        puts "Missing '#{png}', generating..."
        puts `inkscape -o #{png} -w #{SIZE} -h #{SIZE} -b white #{svg}`
        site.static_files << Jekyll::StaticFile.new(site, site.source, '', png)
      end

      ico = 'favicon.ico'
      unless File.exist? ico then
        puts "Missing '#{ico}', generating..."
        puts `convert #{svg} #{ico}`
        site.static_files << Jekyll::StaticFile.new(site, site.source, '', ico)
      end
    end
  end
end