【发布时间】:2018-01-08 17:27:36
【问题描述】:
如下所示,这是一个相当简单的集合设置,其中包含位于根级别的 _events 文件夹中的事件的无序列表(输出设置为 false)。我不想在布局中使用{{ page.title }},而是希望标题读取为月份。
例如,如果我在 _events 集合中添加一个新项目并在前面的内容中包含 month: January,我希望它生成一个“一月”标题,并将该无序列表放在标题下方。同样,如果我添加一个新的集合项并在 front-matter 中包含 month: February,我想生成一个“February”标题,该标题下方有一个新的无序列表。
我知道我需要重新安排标题所在的位置,我想我需要某种类型的 if 声明,但我遇到了障碍。这个我想不通。
Jekyll Collections 可以做到这一点吗?
布局
{% include root.html %}
<div class="flex-main">
{% include header.html %}
<main class="o-main" role="main">
<div class="o-grid-six">
<h1 class="f1 o-grid-six__child c-headline">{{ page.title }}</h1>
</div>
{{ content }}
</main>
</div>
<div class="flex-footer">
{% include footer.html %}
</div>
查看(事件)
---
layout: events
title: Events
order: 2
---
<ul class="c-event-list">
{% for events in site.events %}
<li class="c-event-list__flag">
<div class="c-event-list__flag--left">
<div class="c-event-list__calendar">
<span class="c-event-list__day">{{ events.weekday }}</span>
<span class="f2 c-event-list__date">{{ events.date-number }}</span>
</div>
<img class="c-event-list__image" src="{{ p.url | prepend: site.baseurl }}{{ events.thumb }}" alt="">
</div>
<div class="c-event-list__flag--body">
<div class="c-event-list__content">
<h3 class="f2 c-event-list__title">{{ events.title }}</h3>
<p>{{ events.description }}</p>
<a class="c-button u-mt-2" href="{{ events.link }}">Sign Up</a>
</div>
</div>
</li>
{% endfor %}
</ul>
收藏品(一个事件)
---
layout: default
thumb: /images/event__screen-printing-basics.jpg
link: https://www.eventbrite.com/e/screen-printing-basics-tickets-41882948025
title: Screen Printing Basics
weekday: Wednesday
month: January
date-number: '10'
description: Join us for an after hours session to learn everything you need to know about screen printing in the Make Lab. We will be coating screens with emulsion, printing artwork onto transparencies, burning the image into the screen, washing out the stencil, mixing ink, prepping our work station, registering the paper, and finally pulling prints. The artwork always varies, so you’ll leave with a one-of-a-kind screen printed poster that you made yourself!
---
【问题讨论】: