Last active
July 31, 2016 10:06
-
-
Save fatso83/e403f5ee2500487088ab0598e49a7d91 to your computer and use it in GitHub Desktop.
Example of automatically adding collections to _config.yml
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
require "set" | |
require "pathname" | |
require "yaml" | |
docs_folder = "resources/main-project-repo/docs/" | |
config = YAML.load_file "_config.yml" | |
version_folders = Pathname.new(docs_folder).children.select do |c| | |
c.directory? | |
end | |
doc_versions = version_folders.collect { |pn| pn.basename.to_s } | |
# Add unique new collections to existing | |
if config["collections"] | |
collections = doc_versions.concat(config["collections"]) | |
else | |
collections = doc_versions | |
end | |
config["collections"] = Set.new(collections).to_a | |
print config | |
File.open("_config.yml", 'wb') { |f| YAML.dump(config, f) } | |
# Now do the actual build | |
jekyll build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment