高架:仅在博客文章中添加分页
在高度中,我有一个简单的布局文件,我想在网站上的大多数页面(包括博客集合)中使用该文件。我希望在博客文章中仅添加我的分页部分。
我以下尝试并未将分页添加到任何帖子中。我知道我需要修改if语句,但我不知道如何。如果我不包含if语句,一切正常,但是不在博客集合中的页面从部分中获得一些代码,我不想要。
有什么建议吗?
---
layout: layouts/base.njk
---
<article>
<h1>{{ title }}</h1>
{{ content | safe }}
</article>
{% if post in collections.blog %}
{% include "partials/_pagination.njk" %}
{% endif %}
In Eleventy, I have a simple layout file that I'd like to use for most pages on my website, including the blog collection. I'd like the layout to only add my pagination partial when in a blog post.
My attempt below doesn't add the pagination partial to any post. I know I need to modify the if statement, but I don't know how. Everything works fine if I don't include the if statement, but pages not in the blog collection get some of the code from partial, which I don't want.
Any suggestions?
---
layout: layouts/base.njk
---
<article>
<h1>{{ title }}</h1>
{{ content | safe }}
</article>
{% if post in collections.blog %}
{% include "partials/_pagination.njk" %}
{% endif %}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得到了高度不和谐小组的答案:
I got the answer from the Eleventy group on Discord: