Skip to content

Instantly share code, notes, and snippets.

@imathis
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imathis/a88b5f13ddff1e2089b2 to your computer and use it in GitHub Desktop.
Save imathis/a88b5f13ddff1e2089b2 to your computer and use it in GitHub Desktop.
# Pretty much pseduo code
# Let's just assume you're in a loop where you are generating each post
new_data = {
'title' => 'Some new title for this generated post post'
}
site.posts << Series::Post.new(site, site.source, index, post, new_data)
module Series
class Post < Jekyll::Post
# index - the paginated number
# original_post - the post which this pagination is generated from
# new_data - overrides for YAML front-matter
def initialize(site, base, index, original_post, new_data={})
@site = site
@base = base
@dir = File.join(original_post.url, index.to_s) # will end up at [original_post_permalink]/[index]/index.html
@name = 'index.html'
process(name)
# Read from the original post so Jekyll doesn't freak out about this post not being on the filesystem
read_yaml(File.join(base, File.dirname(original_post.path)), File.basename(original_post.path))
# Override yaml front-matter from the original post
self.data.merge!(new_data)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment