Skip to content

search.pages() and search.page() should return the data object instead of the full Page instance. #251

@oscarotero

Description

@oscarotero

This makes working with pages easier. For example, instead of this:

{% for article in search.pages("type=article", "date=desc") %} 
<a href="{{ article.data.url }}">
  <h1>{{ article.data.title }}</h1>
</a>
{% endfor %}

It would become to this:

{% for article in search.pages("type=article", "date=desc") %} 
<a href="{{ article.url }}">
  <h1>{{ article.title }}</h1>
</a>
{% endfor %}

If it's necesary to access to the Page instance (to get the src data, for example) it's available at data.page. Example:

{% for article in search.pages("type=article", "date=desc") %} 
<a href="{{ article.url }}">
  <h1>{{ article.title }}</h1>
  Loaded from {{ article.page.src.path }}
</a>
{% endfor %}

Due this is a breaking change, it will be in Lume 2.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions