【发布时间】:2018-10-23 14:25:55
【问题描述】:
我正在尝试在 Jekyll 上创建我的第一个博客。我被困在一件事上:我的一个类别有一个部分,比如说“新闻”:
<section class="news">
<div class="container">
<div class="row no-gutters">
{% for post in site.categories.news limit: 2 offset: 0 %}
{% include news-item-col-6.html %}
{% endfor %}
{% for post in site.categories.news limit: 3 **offset: 2** %}
{% include news-item-col-4.html %}
{% endfor %}
</div>
</div>
</section>
news-item-col-6:
{% if post.thumb != 0 %}
<div class="col-md-6">
<div class="pattern">
<div class="overlay item-title" style="background-image: url({{ post.thumb }});">
<div class="item-title-content">
<h3><a href="{{ post.url }}">{{ post.header }}</a></h3>
</div>
</div>
</div>
</div>
{% endif %}
news-item-col-4:
{% if post.thumb != 0 %}
<div class="col-md-4">
<div class="pattern">
<div class="overlay item-title" style="background-image: url({{ post.thumb }});">
<div class="item-title-content">
<h3><a href="{{ post.url }}">{{ post.header }}</a></h3>
</div>
</div>
</div>
</div>
{% endif %}
我的帖子
---
layout: post
title: title | site.com
header: title
description: description
categories: categories url
catname: News
image: "images/URL /to image/1.jpg"
thumb: "images/URL /to thumb/1t.jpg"
permalink: "blog/:categories/:year-:month-:day-:slug.html"
---
问题是不是我所有的帖子都会有背景拇指,我想做的就是忽略没有post.thumb的帖子。并且代码有效,但不幸的是col-md-4 块的偏移量没有忽略没有post.thumb 的帖子顺序。
下面的图片显示了我想要的:
- This is how should be, if all my posts have post.thumb(bg_image)
- This is how should be, if my post Item2 has no post.thumb(bg_image), it just not showing up in section
- And this is how my code works
那么我应该怎么做才能让它正常工作呢?
【问题讨论】:
标签: jekyll liquid offset posts