Last active
August 29, 2015 14:15
-
-
Save imathis/a88b5f13ddff1e2089b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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) |
This file contains hidden or 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
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