Skip to content

Instantly share code, notes, and snippets.

@zmoazeni
Created June 11, 2017 03:25
Show Gist options
  • Save zmoazeni/4241c4908cb3f9ced40482e100560b6c to your computer and use it in GitHub Desktop.
Save zmoazeni/4241c4908cb3f9ced40482e100560b6c to your computer and use it in GitHub Desktop.
module Jekyll
class VersionedPage < Page
def initialize(site, base, dir, version, post)
@site = site
@base = base
@dir = dir
@name = "#{version}/#{post.url}#{post.data["ext"]}"
process(@name)
self.content = post.content
self.data = post.data
self.data["layout"] = "#{version}/post"
end
end
class VersionGenerator < Generator
VERSIONS = ["v2013"]
def generate(site)
VERSIONS.each do |version|
site.posts.docs.each do |post|
site.pages << VersionedPage.new(site, site.source, "", version, post)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment