跳到主要内容

作者

本页 API 自 Halo 2.0.0 起可用。

getContributor(name)​

contributorFinder.getContributor(name);

描述​

根据 metadata.name 获取作者。

参数​

  1. name:string - 作者的唯一标识 metadata.name。

返回值​

#ContributorVo

示例​

<div
th:with="contributor = ${contributorFinder.getContributor('contributor-foo')}"
>
<h1 th:text="${contributor.displayName}"></h1>
</div>

getContributors(names)​

contributorFinder.getContributors(names);

描述​

根据一组 metadata.name 获取作者。

参数​

  1. names:List<string> - 作者的唯一标识 metadata.name 的集合。

返回值​

List<#ContributorVo>

示例​

<div
th:with="contributors = ${contributorFinder.getContributors({'contributor-foo', 'contributor-bar'})}"
>
<span
th:each="contributor : ${contributors}"
th:text="${contributor.displayName}"
></span>
</div>

类型定义​

ContributorVo​

ContributorVo
{
"name": "string", // 用户名
"displayName": "string", // 显示名称
"avatar": "string", // 头像
"bio": "string", // 描述
"permalink": "string", // 作者的文章归档页面链接
"metadata": {
"name": "string", // 唯一标识
"labels": {
"additionalProp1": "string",
},
"annotations": {
"additionalProp1": "string",
},
"creationTimestamp": "2022-11-20T13:06:38.512Z", // 创建时间
},
}