Last active
August 29, 2015 14:06
-
-
Save lpil/ab07b5d658c600e048a4 to your computer and use it in GitHub Desktop.
Generate a list of URLs used by each jekyll site subdirectory of cwd
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# Generate a list of URLs used by each jekyll site subdirectory of cwd | |
template = <<-END | |
--- | |
layout: none | |
--- | |
/* | |
* {{ site.title }} | |
*/ | |
{% for page in site.pages %}{{ page.url }} | |
{% endfor %}{% for post in site.posts %}{{ post.url }} | |
{% endfor %} | |
END | |
urls = '' | |
Dir.glob('*/').reject { |dir| dir.match(/scss/) }.each do |dir| | |
puts "Generating URLs for #{dir}" | |
Dir.chdir dir | |
File.write 'urls.txt', template | |
`jekyll build` | |
urls << File.read('_site/urls.txt') | |
File.delete 'urls.txt' | |
Dir.chdir '..' | |
end | |
File.write 'urls.txt', urls.gsub(/\/urls\.txt\n/, '') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment