Skip to content

Instantly share code, notes, and snippets.

@fotos
Created April 9, 2012 07:29
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 fotos/2342129 to your computer and use it in GitHub Desktop.
Save fotos/2342129 to your computer and use it in GitHub Desktop.
--- redirect.rb 2012-04-09 11:58:39.905024214 +0300
+++ redirect-pages.rb 2012-04-09 11:58:10.441025135 +0300
@@ -15,9 +15,9 @@
# find all posts with a redirect property and create a new page for each entry
def generate_redirects(site)
- site.posts.select{|x| x.data.key? 'redirects' }.each do |p|
+ (site.pages + site.posts).select{|x| x.data.key? 'redirects' }.each do |p|
p.data['redirects'].each do |r|
- redirect = RedirectPage.new(site, site.source, r, p.id)
+ redirect = RedirectPage.new(site, site.source, r, p.url)
redirect.render(site.layouts, site.site_payload)
redirect.write(site.dest)
site.pages << redirect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment