Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Issue with post frontmatter and pagination #303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thoemmi
Copy link
Contributor

@thoemmi thoemmi commented Jul 8, 2016

I have some problems when using post's frontmatter and paginating. Additional properties I define in the a post's frontmatter are not available when I use pagination.

E.g. I have this post:


---
layout: default
title: 'Some post'
customfield: 'bar'

---
## Hello World!

And my index.html look like this


---
layout: default
paginate: 1
title: 'A different title'

---
{% for post in paginator.posts %}
  {{ post.title }}-{{ post.customfield }}
{% endfor %}

Then the first page is rendered with

  Some post-

but I expect

  Some post-bar

I'm always confused by Pretzel's code: on the one hand PageContext has several properties, and on the other hand it has a Bag, where some of the properties are duplicated.

This PR contains "only" a unit test to reproduce the issue. I don't know how to fix it at the moment.

@laedit
Copy link
Member

laedit commented Jul 9, 2016

Thanks a lot for the reporting 😃
I know that the paginator is kind of "weird" at best, but I hadn't take the time to investigate it.
Seems the time has come!

@laedit
Copy link
Member

laedit commented Jul 9, 2016

So finally it is not linked to the paginatordirectly but by the way we populate the liquid's template data in LiquidEngine: the paginator is passed directly without processing the data of each of his posts.

So right now the customfield is accessible through post.bag["customfield"].
An evolution could be to pass the paginator in LiquidEngine.CreatePageData but to call a ToHash method, like the one used on ContextDrop, which will return a Hash of all properties of paginator and call ToHash on each Page.

About PageContext, I think it is because Razor is also supported: it doesn't use page.customfield but @Model.Bag["customfield"] to access to custom values in page. So the properties are needed to facilitate the access to usual values.

@laedit laedit self-requested a review January 19, 2017 15:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants