Skip to content

Commit

Permalink
Set correct file name and dir on generated pages
Browse files Browse the repository at this point in the history
Because Jekyll caches parsed templates by filename[1], not setting a
correct unique one will result in all generated pages being rendered
with the same template.

Fixes sverrirs#209.

[1] https://github.com/jekyll/jekyll/blob/67380a273888abaef96a1f37239e6a5f9eda8205/lib/jekyll/liquid_renderer/file.rb#L13
  • Loading branch information
salomvary committed Dec 19, 2020
1 parent 25b0d43 commit 234696d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/jekyll-paginate-v2/generator/paginationModel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ def paginate(template, config, site_title, all_posts, all_tags, all_categories,
newpages = []

# Consider the default index page name and extension
indexPageName = config['indexpage'].nil? ? '' : config['indexpage'].split('.')[0]
indexPageExt = config['extension'].nil? ? '' : Utils.ensure_leading_dot(config['extension'])
indexPageName = config['indexpage'].nil? ? 'index' : config['indexpage'].split('.')[0]
indexPageExt = config['extension'].nil? ? '.html' : Utils.ensure_leading_dot(config['extension'])
indexPageWithExt = indexPageName + indexPageExt

# In case there are no (visible) posts, generate the index file anyway
Expand Down Expand Up @@ -308,6 +308,8 @@ def paginate(template, config, site_title, all_posts, all_tags, all_categories,
newpage.set_url(newpage.pager.page_path+indexPageExt)
end

newpage.dir = File.dirname(newpage.pager.page_path)

if( template.data['permalink'] )
newpage.data['permalink'] = newpage.pager.page_path
end
Expand Down

0 comments on commit 234696d

Please sign in to comment.