liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
##
# Create individual pages for each icon in the FontAwesome set
 
require 'yaml'
 
module Jekyll
 
  class IconPage < Page
 
    ##
    # Take a single icon and render a page for it.
 
    def initialize(site, base, dir, icon)
      @site = site
      @base = base
      @dir = dir
      @name = "#{icon.id}.html"
      @icon = icon
 
      self.process(@name)
 
      self.read_yaml(File.join(base, site.config['layouts']), site.config['icon_layout'])
 
      self.data['icon'] = icon
      self.data['title'] = "fa-#{icon.id}: " + self.data['title_suffix']
    end
 
  end
 
  class IconGenerator < Generator
 
    ##
    # Iterate over every described icon in a YAML file and create a page for it
 
    safe true
 
    def generate(site)
      site.icons.each do |icon|
        site.pages << IconPage.new(site, site.source, site.config['icon_destination'], icon)
      end
    end
 
  end
 
end