Browse code

Created repository.

DoubleBastionAdmin authored on 02/03/2022 00:26:46
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,45 @@
1
+##
2
+# Create individual pages for each icon in the FontAwesome set
3
+
4
+require 'yaml'
5
+
6
+module Jekyll
7
+
8
+  class IconPage < Page
9
+
10
+    ##
11
+    # Take a single icon and render a page for it.
12
+
13
+    def initialize(site, base, dir, icon)
14
+      @site = site
15
+      @base = base
16
+      @dir = dir
17
+      @name = "#{icon.id}.html"
18
+      @icon = icon
19
+
20
+      self.process(@name)
21
+
22
+      self.read_yaml(File.join(base, site.config['layouts']), site.config['icon_layout'])
23
+
24
+      self.data['icon'] = icon
25
+      self.data['title'] = "fa-#{icon.id}: " + self.data['title_suffix']
26
+    end
27
+
28
+  end
29
+
30
+  class IconGenerator < Generator
31
+
32
+    ##
33
+    # Iterate over every described icon in a YAML file and create a page for it
34
+
35
+    safe true
36
+
37
+    def generate(site)
38
+      site.icons.each do |icon|
39
+        site.pages << IconPage.new(site, site.source, site.config['icon_destination'], icon)
40
+      end
41
+    end
42
+
43
+  end
44
+
45
+end