如何在页面的特定位置显示一些帖子?
How to display some of the posts in specific places on page?
我想在页面中间显示特定 post 以及其他常规 post(检查屏幕截图)
我知道我可以将 front matter 与 featured: true
之类的东西一起使用,但是还有其他方法可以做到这一点吗?
简单。只需这样做:
{% for post in site.posts %}
{% if forloop.index == 1 or forloop.index == 4 %}
output wide post
{% else %}
output normal post
{% endif %}
{% endfor %}
更好的答案:围绕每个 post 创建类似的 div,然后用 CSS 定位它们,如下所示:
div {width: 50℅;}
div:nth-child(1), div:nth-child(4) {width: 100%;}
如果可能,布局应在 CSS。
我想在页面中间显示特定 post 以及其他常规 post(检查屏幕截图)
我知道我可以将 front matter 与 featured: true
之类的东西一起使用,但是还有其他方法可以做到这一点吗?
简单。只需这样做:
{% for post in site.posts %}
{% if forloop.index == 1 or forloop.index == 4 %}
output wide post
{% else %}
output normal post
{% endif %}
{% endfor %}
更好的答案:围绕每个 post 创建类似的 div,然后用 CSS 定位它们,如下所示:
div {width: 50℅;}
div:nth-child(1), div:nth-child(4) {width: 100%;}
如果可能,布局应在 CSS。