Created
June 19, 2018 15:59
-
-
Save cameronmcefee/b587a31cc9abf675b5605b89950a26ec to your computer and use it in GitHub Desktop.
A Jekyll plugin to load all environment variables that start with "JEKYLL_" into the Jekyll config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
class EnvironmentVariablesGenerator < Generator | |
# Pass any environment variables that start with JEKYLL_ on to Jekyll, where | |
# they can be access on the `site` object, like {{ site.JEKYLL_MY_VAR }} | |
def generate(site) | |
keys = ENV.keys.select { |i| i[/^JEKYLL_/] } | |
keys.each { |k| site.config[k] = ENV[k] } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment