jekyll - 文章列表中的 jekyll 作者图片
问题描述
如果我在集合中定义了 id,请问如何显示作者的个人形象:
我的收藏/_authors/
name: John Doe
image: assets/img/photo-john.jpg
layout: author
permalink: "/authors/john-doe/"
如何在文章循环中显示它?
{% for post in site.posts %}
{% assign author = site.authors[page.author] %}
<img src="{{ site.baseurl }}/{{ author.image }}" alt="{{ post.author }}" class="avatar avatar-sm">
{% endfor %}
解决方案
{{ author.image }}
和怎么样relative_url
?
我假设image
是图像的网址。
在降价中
{% for post in site.posts %}
{% assign author = site.authors[page.author] %}
{: .avatar .avatar-sm }
![{{ post.author }}]({{ author.image | relative_url }})
{% endfor %}
在 html 中
{% for post in site.posts %}
{% assign author = site.authors[page.author] %}
<img src="{{ author.image | relative_url }}" alt="{{ post.author }}" class="avatar avatar-sm">
{% endfor %}
推荐阅读
- javascript - 重定向未正确重新加载页面
- laravel - Laravel 在包含多个额外字段的多对多上使用同步
- pandas - 在数据框列周围带有布尔条件的嵌套 if 语句
- swift - 如何基于 Int 创建新的类型安全原始类型?
- javascript - 反应构建块文件和清单 json 中的意外语法错误
- oracle-apex - 如何防止应用程序在 Google Chrome 中打开
- ios - Swift 组合:`first(_ n: Int)` 等价于 RxSwift `take(_ n: Int)`?
- python - Sklearn(NLP 文本分类器新手) - 形状和矢量化器的问题,X 和 Y 不匹配
- angular - 如何在 Angular Storybook 组件中注入服务?
- python - 如何恢复旧的python