Skip to content

Instantly share code, notes, and snippets.

@lpil
Last active August 29, 2015 14:06
Show Gist options
  • Save lpil/ab07b5d658c600e048a4 to your computer and use it in GitHub Desktop.
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
#!/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