jekyll-TeXt-theme icon indicating copy to clipboard operation
jekyll-TeXt-theme copied to clipboard

Feature request: better support for collection-like pages

Open mincong-h opened this issue 4 years ago • 0 comments

Description

Currently, we have to provide a data_source variable to use the articles layout. But that means creating a collection explicitly for the articles that we want to show. It's a lot of work and hard to maintain. But actually the HTML file article-list.html accepts a list of posts as input as parameter articles, for example here:

{%- include article-list.html articles=site.sample_languages type='grid' size='sm' -%}

What about adding support for collection-like pages, such as a list of posts related to a given tag or a given category? The syntax can be done as:

{%- include article-list.html articles=site.tags['my_tag'] type='grid' size='sm' -%}
{%- include article-list.html articles=site.categories['my_category'] type='grid' size='sm' -%}

Proposals

Create a new layout called "category" or "tag", allow user to provide one category or one tag in front matter. This will list all the posts related to that category or that tag.

---
layout: page
---

{{ content }}

<div class="layout--articles">
  <section class="my-5">
    {% assign _articles = site.categories[page.category] %}
    {%- include article-list.html articles=_articles type='grid' size='md' -%}
  </section>
</div>

mincong-h avatar Feb 15 '21 22:02 mincong-h