mirror of
https://github.com/adulau/art.git
synced 2024-11-25 11:37:12 +00:00
Fix bug where some pages where not shown as tiles.
This commit refactors the `tiles.html` include file so that when the `site.tiles-source` is pages, pages with `show_tile: false` set in their Front Matter are not counted as having been shown. Prior to this commit, such pages were iterated over in the `for` loop, consuming a loop iteration from the `site.tiles-count` counter. Put another way, say you have set `tiles-count` to 6, and you have a total of 10 pages. Of these ten pages, six have `show_tile` set to `false`. The natural expectation would be that the home page layout would display four tiles (10 - 6 = 4), but in fact, the exact number of page tiles shown would depend on the specific lexicographical ordering of the `site.html_pages` array, which could result in fewer than four page tiles being shown. This commit fixes the issue by excluding pages with `show_tile` set to `false` first, and only then iterating over the remaining pages.
This commit is contained in:
parent
8c70ecf005
commit
4e4f981b8c
1 changed files with 8 additions and 18 deletions
|
@ -1,28 +1,18 @@
|
||||||
|
{% if 'posts' == site.tiles-source %}
|
||||||
|
{% assign tiles = site.posts %}
|
||||||
|
{% elsif 'pages' == site.tiles-source %}
|
||||||
|
{% assign tiles = site.html_pages | where_exp: "item", "item.show_tile != false" %}
|
||||||
|
{% endif %}
|
||||||
<section id="one" class="tiles">
|
<section id="one" class="tiles">
|
||||||
{% for post in site.posts limit:site.tiles-count %}
|
{% for tile in tiles limit:site.tiles-count %}
|
||||||
{% if site.tiles-source == 'posts' %}
|
|
||||||
<article>
|
<article>
|
||||||
<span class="image">
|
<span class="image">
|
||||||
<img src="{{ post.image }}" alt="" />
|
<img src="{{ tile.image }}" alt="" />
|
||||||
</span>
|
</span>
|
||||||
<header class="major">
|
<header class="major">
|
||||||
<h3><a href="{{ post.url | relative_url }}" class="link">{{ post.title }}</a></h3>
|
<h3><a href="{{ tile.url | relative_url }}" class="link">{{ tile.title }}</a></h3>
|
||||||
<p>{{ post.description }}</p>
|
<p>{{ post.description }}</p>
|
||||||
</header>
|
</header>
|
||||||
</article>
|
</article>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% for page in site.html_pages limit:site.tiles-count %}
|
|
||||||
{% if site.tiles-source == 'pages' and page.show_tile != false %}
|
|
||||||
<article>
|
|
||||||
<span class="image">
|
|
||||||
<img src="{{ page.image }}" alt="" />
|
|
||||||
</span>
|
|
||||||
<header class="major">
|
|
||||||
<h3><a href="{{ page.url | relative_url }}" class="link">{{ page.title }}</a></h3>
|
|
||||||
<p>{{ page.description }}</p>
|
|
||||||
</header>
|
|
||||||
</article>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue