Class: Hyde::Fonts
- Inherits:
-
Object
- Object
- Hyde::Fonts
- Defined in:
- lib/hyde-fonts.rb,
lib/hyde_fonts/hyde_fonts.rb
Constant Summary collapse
- VERSION =
"0.3.4"
- @@config =
{ "data_source_name" => "fonts", "file_output_path" => "assets/fonts", "css_output_name" => "fonts.css", "css_minify" => true, "enable" => true, "fetch_fonts" => true, "keep_files" => true }
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(site) ⇒ Fonts
constructor
A new instance of Fonts.
Constructor Details
#initialize(site) ⇒ Fonts
Returns a new instance of Fonts.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/hyde_fonts/hyde_fonts.rb', line 93 def initialize(site) @site = site @config = site.config.dig("hyde_fonts") if @config.nil? @config = @@config site.config["hyde_fonts"] = @config end if config("keep_files") == true @site.config["keep_files"].push(config("file_output_path")) end if site.config.dig("hyde_fonts").nil? @site.config["hyde_fonts"] = @config end end |
Instance Method Details
#generate ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/hyde_fonts/hyde_fonts.rb', line 111 def generate return unless config("enable") == true # get faces from jekyll data file font_data = Hyde::FontData.new(data) # handle font providers for face in font_data.faces Jekyll.logger.info("Fonts:", "Preparing #{face.name}") case face.provider when "google" Hyde::FontProviderGoogle.new(@site, @config).fetch(face) when "local" # TODO handle local fonts # Hyde::FontProviderLocal.new(@site, @config).fetch(face) end end css = font_data.faces.map { |face| face.css } # generate static file containing face css rulesets css_file = Hyde::GeneratedCssFile.new(@site, config("file_output_path"), config("css_output_name")) css_file.file_contents = minify(css.join("\n")) @site.static_files << css_file end |