jekyll build hook to create gz versions of each .html file
There is no hook in jekyll build
.
The only way to generate additional content is to write a generator plugin.
If your goal is to serve the gzipped version of you pages, you must know that github pages already serves gzipped html, css and js.
Generate json array of directory in Ruby?
You can use globs and wildcards with Ruby's Dir class. You could get an array of .html files recursively from the current directory, using something along the lines of files = Dir['./**/*.html']
.
To generate JSON, you'd want to first ensure that the person using your plugin has access to a JSON library (require 'json'
) and then use the #to_json
helper method on your files array: files.to_json
Get Jekyll Data Files inside Converter Plugin
Edit : As context.registers[:site] is not available in Converter plugins.
But you can use this dirty trick:
def initialize(config)
dir = config['data_source']
filePath = File.join(dir, 'links.yml')
data = SafeYAML.load_file(filePath)
end
Does Jekyll process files with no front matter?
Because GitHub Pages auto-loads the jekyll-optional-front-matter
package as a dependency, your markdown files without a front matter do work on your GitHub Pages hosted site.
https://github.com/benbalter/jekyll-optional-front-matter explains why:
Out of the box, Jekyll requires that any markdown file have YAML front matter (key/value pairs separated by two sets of three dashes) in order to be processed and converted to HTML.
While that behavior may be helpful for large, complex sites, sometimes it's easier to simply add a plain markdown file and have it render without fanfare.
This plugin does just that. Any Markdown file in your site's source will be treated as a Page and rendered as HTML, even if it doesn't have YAML front matter.
Related Topics
Can't Get Rack-Cors Working in Rails Application
What's the Best Way to Talk to a Database While Using Sinatra
Best Ruby Idiom for "Nil or Zero"
Homebrew Install: Failed During: Git Fetch Origin Master:Refs/Remotes/Origin/Master -N --Depth=1
Conditional Key/Value in a Ruby Hash
How to Set the Default String Encoding on Ruby 1.9
How to Install Ruby-Debug in Ruby 1.9.3/Rails 3.2.1
Rails: Copying Attributes from an Object to Another Using the "Attributes" Method
Maintaining Cookies Between Mechanize Requests
How to Add MAC-Specific Gems to Bundle on MAC But Not on Linux
Difference Between '%{}', '%Q{}', '%Q{}' in Ruby String Delimiters
Ruby To_JSON Issue with Error "Illegal/Malformed Utf-8"