Jekyll 如何使用标记集合
我收集了一些作者的作品 我想通过以下方式为我的帖子分配作者标签:Jekyll 如何使用标记集合,jekyll,liquid,Jekyll,Liquid,我收集了一些作者的作品 我想通过以下方式为我的帖子分配作者标签: {% assign author = site.authors | where: "title", page.author | first %} {% if author %} <a href="{{ author.url }}">{{ author.title }}</a> {% endif %} Frontmatter集合条目示例: --- title: Building date: 20
{% assign author = site.authors | where: "title", page.author | first %}
{% if author %}
<a href="{{ author.url }}">{{ author.title }}</a>
{% endif %}
Frontmatter集合条目示例:
---
title: Building
date: 2017-01-11 16:22:51 +0100
author: Bob Baumeister
---
Content
---
title: Bob Baumeister
twitter: bobby
---
Content
谢谢你的帮助。试试“
:
author: "Bob Baumeister"
更新
你能举一个作者输入的例子吗?这可能是由于使用了过滤器“first”,选择作者姓名中的第一个字符串,用一个页面示例更新问题。作者示例及其在数据文件中的条目@David:是的,我在上面添加了一些示例。@user3473628上面的示例对我有效,您试图替换哪个标题?@marcanuy它应该是指向“Bob Baumeister”中所有帖子所在列表的链接已列出。对我来说,它只适用于名字。示例:如果我只使用“Bob”,则在我的帖子中会显示一个链接。“Bob Baumeister”没有。谢谢你的提示。在我的帖子里试过了。但是不起作用。如果我只使用一个名字,比如
Bob
,它就行了。Bob Baumeister也能工作。只有鲍勃·鲍迈斯特(Bob Baumeister)不起作用……这是正确的方法。因为page.author
被删除了,网站上的“标题”也被删除了。authors not我在authors集合中添加了另一个标签,比如authors\u slug
,内容为bob baumeister
,或者也可以删除“标题”吗?谢谢是的,您可以将slug
过滤器应用于您想要的任何字符串,例如{%assign slug=“Title With spaces”| slagify%}
<!-- Bob Bau => bob-bau -->
{% assign slug = page.author | slugify %}
<!-- filter by the slugified title -->
{% assign author = site.authors | where: "title", slug | first%}
...
- name: Bob Baumeister
title: bob-baumeister
url: /bob-baumeister
- name: Henri Beyle
title: Stendhal
url: /stendhal
- name: Jon Doe
title: jon-doe
url: https://author.jo