Created
August 21, 2014 18:01
-
-
Save changemewtf/e70e784ec57ef72b1c33 to your computer and use it in GitHub Desktop.
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
class CodefileGenerator < Jekyll::Generator | |
NON_CODE_EXTENSIONS = [ | |
'html', | |
'md' | |
] | |
is_dotfile = proc { |f| ['.', '..'].include? f } | |
f_ext = proc { |f| f.slice /\.(.*)$/, 1 } | |
is_non_codefile = proc { |f| non_code_extensions.include? f_ext[f] } | |
def generate(site) | |
site.pages.each do |page| | |
dir = File.dirname(page.path) | |
if !File.exists? dir | |
# for generated pages (like week schedules) | |
next | |
end | |
codefiles = Dir.entries(dir) | |
.reject(&is_dotfile) | |
.reject(&is_non_codefile) | |
page.data['codefiles'] = codefiles | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment