Skip to content

Instantly share code, notes, and snippets.

@derekconjar
Created May 3, 2014 16:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekconjar/e4c0012e17f570ebe923 to your computer and use it in GitHub Desktop.
Save derekconjar/e4c0012e17f570ebe923 to your computer and use it in GitHub Desktop.
Custom page directories in Middleman. Keep different kinds of pages (like landing pages and reports) separate, but give them all pretty URLs.
page_dirs = ["pages", "landing", "reports"]
page_dirs.each do |page_dir|
pages = Dir.glob("./source/#{page_dir}/*.html*")
pages.each do |page_path|
pattern = /.\/source\/#{page_dir}\/([^\.]*)\..*/
page = page_path.match(pattern).captures[0]
page "/#{page}/*", :layout => :layout
proxy "/#{page}/index.html", "/#{page_dir}/#{page}.html", :ignore => true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment