文章
getByName(postName)
postFinder.getByName(postName)
描述
根据 metadata.name
获取文章。
参数
postName:string
- 文章的唯一标识metadata.name
。
返回值
示例
<div th:with="post = ${postFinder.getByName('post-foo')}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}"></a>
</div>
content(postName)
postFinder.content(postName)
描述
根据文章的 metadata.name
单独获取文章内容。
参数
postName:string
- 文章的唯一标识metadata.name
。
返回值
示例
<div th:with="content = ${postFinder.content('post-foo')}">
<div th:utext="${content.content}"></div>
</div>
cursor(postName)
postFinder.cursor(postName)
描述
根据文章的 metadata.name
获取相邻的文章(上一篇 / 下一篇)。
参数
postName:string
- 文章的唯一标识metadata.name
。
返回值
示例
/templates/post.html
<div
th:with="postCursor = ${postFinder.cursor(post.metadata.name)}"
>
<a
th:if="${postCursor.hasPrevious()}"
th:href="@{${postCursor.previous.status.permalink}}"
>
<span th:text="${postCursor.previous.spec.title}"></span>
</a>
<a
th:if="${postCursor.hasNext()}"
th:href="@{${postCursor.next.status.permalink}}"
>
<span th:text="${postCursor.next.spec.title}"></span>
</a>
</div>
listAll()
postFinder.listAll()
描述
获取所有文章。
参数
无
返回值
List<#ListedPostVo>
示例
<ul th:with="posts = ${postFinder.listAll()}">
<li th:each="post : ${posts}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}"></a>
</li>
</ul>
list(page,size)
postFinder.list(page,size)
描述
根据分页参数获取文章列表。
参数
page:int
- 分页页码,从 1 开始size:int
- 分页条数
返回值
示例
<ul th:with="posts = ${postFinder.list(1,10)}">
<li th:each="post : ${posts.items}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}"></a>
</li>
</ul>
listByCategory(page,size,categoryName)
postFinder.listByCategory(page,size,categoryName)
描述
根据分类标识和分页参数获取文章列表。
参数
page:int
- 分页页码,从 1 开始size:int
- 分页条数categoryName:string
- 文章分类唯一标识metadata.name
返回值
示例
<ul th:with="posts = ${postFinder.listByCategory(1,10,'category-foo')}">
<li th:each="post : ${posts.items}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}"></a>
</li>
</ul>
listByTag(page,size,tag)
postFinder.listByTag(page,size,tag)
描述
根据标签标识和分页参数获取文章列表。
参数
page:int
- 分页页码,从 1 开始size:int
- 分页条数tag:string
- 文章分类唯一标识metadata.name
返回值
示例
<ul th:with="posts = ${postFinder.listByTag(1,10,'tag-foo')}">
<li th:each="post : ${posts.items}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}"></a>
</li>
</ul>
archives(page,size)
postFinder.archives(page,size)
描述
根据分页参数获取文章归档列表。
参数
page:int
- 分页页码,从 1 开始size:int
- 分页条数
返回值
示例
<th:block th:with="archives = ${postFinder.archives(1,10)}">
<th:block th:each="archive : ${archives.items}">
<h1 th:text="${archive.year}"></h1>
<ul>
<th:block th:each="month : ${archive.months}">
<li th:each="post : ${month.posts}">
<a
th:href="@{${post.status.permalink}}"
th:text="${post.spec.title}">
</a>
</li>
</th:block>
</ul>
</th:block>
</th:block>
archives(page,size,year)
postFinder.archives(page,size,year)
描述
根据年份和分页参数获取文章归档列表。
参数
page:int
- 分页页码,从 1 开始size:int
- 分页条数year:string
- 年份
返回值
示例
<th:block th:with="archives = ${postFinder.archives(1,10,'2022')}">
<th:block th:each="archive : ${archives.items}">
<h1 th:text="${archive.year}"></h1>
<ul>
<th:block th:each="month : ${archive.months}">
<li th:each="post : ${month.posts}">
<a
th:href="@{${post.status.permalink}}"
th:text="${post.spec.title}">
</a>
</li>
</th:block>
</ul>
</th:block>
</th:block>
archives(page,size,year,month)
postFinder.archives(page,size,year,month)
描述
根据年月和分页参数获取文章归档列表。
参数
page:int
- 分页页码,从 1 开始size:int
- 分页条数year:string
- 年份month:string
- 月份
返回值
示例
<th:block th:with="archives = ${postFinder.archives(1,10,'2022','11')}">
<th:block th:each="archive : ${archives.items}">
<h1 th:text="${archive.year}"></h1>
<ul>
<th:block th:each="month : ${archive.months}">
<li th:each="post : ${month.posts}">
<a
th:href="@{${post.status.permalink}}"
th:text="${post.spec.title}">
</a>
</li>
</th:block>
</ul>
</th:block>
</th:block>
类型定义
CategoryVo
CategoryVo
{
"metadata": {
"name": "string",
"labels": {
"additionalProp1": "string"
},
"annotations": {
"additionalProp1": "string"
},
"creationTimestamp": "2022-11-20T13:06:38.512Z",
},
"spec": {
"displayName": "string",
"slug": "string",
"description": "string",
"cover": "string",
"template": "string",
"priority": 0,
"children": [
"string"
]
},
"status": {
"permalink": "string",
"postCount": 0,
"visiblePostCount": 0
},
"postCount": 0
}
TagVo
TagVo
{
"metadata": {
"name": "string",
"labels": {
"additionalProp1": "string"
},
"annotations": {
"additionalProp1": "string"
},
"creationTimestamp": "2022-11-20T13:06:38.512Z",
},
"spec": {
"displayName": "string",
"slug": "string",
"color": "#F9fEB1",
"cover": "string"
},
"status": {
"permalink": "string",
"visiblePostCount": 0,
"postCount": 0
},
"postCount": 0
}
PostVo
PostVo
{
"metadata": {
"name": "string",
"labels": {
"additionalProp1": "string"
},
"annotations": {
"additionalProp1": "string"
},
"creationTimestamp": "2022-11-20T12:45:43.888Z",
},
"spec": {
"title": "string",
"slug": "string",
"releaseSnapshot": "string",
"headSnapshot": "string",
"baseSnapshot": "string",
"owner": "string",
"template": "string",
"cover": "string",
"deleted": false,
"publish": false,
"publishTime": "2022-11-20T12:45:43.888Z",
"pinned": false,
"allowComment": true,
"visible": "PUBLIC",
"priority": 0,
"excerpt": {
"autoGenerate": true,
"raw": "string"
},
"categories": [
"string"
],
"tags": [
"string"
],
"htmlMetas": [
{
"additionalProp1": "string"
}
]
},
"status": {
"permalink": "string",
"excerpt": "string",
"commentsCount": 0,
"contributors": [
"string"
]
},
"categories": "List<#CategoryVo>",
"tags": "List<#TagVo>",
"contributors": [
{
"name": "string",
"displayName": "string",
"avatar": "string",
"bio": "string"
}
],
"owner": {
"name": "string",
"displayName": "string",
"avatar": "string",
"bio": "string"
},
"stats": {
"visit": 0,
"upvote": 0,
"comment": 0
},
"content": {
"raw": "string",
"content": "string"
}
}
ContentVo
ContentVo
{
"raw": "string",
"content": "string"
}
NavigationPostVo
NavigationPostVo
{
"previous": "#PostVo",
"current": "#PostVo",
"next": "#PostVo"
}
ListedPostVo
ListedPostVo
{
"metadata": {
"name": "string",
"labels": {
"additionalProp1": "string"
},
"annotations": {
"additionalProp1": "string"
},
"creationTimestamp": "2022-11-20T13:06:38.505Z",
},
"spec": {
"title": "string",
"slug": "string",
"releaseSnapshot": "string",
"headSnapshot": "string",
"baseSnapshot": "string",
"owner": "string",
"template": "string",
"cover": "string",
"deleted": false,
"publish": false,
"publishTime": "2022-11-20T13:06:38.505Z",
"pinned": false,
"allowComment": true,
"visible": "PUBLIC",
"priority": 0,
"excerpt": {
"autoGenerate": true,
"raw": "string"
},
"categories": [
"string"
],
"tags": [
"string"
],
"htmlMetas": [
{
"additionalProp1": "string"
}
]
},
"status": {
"permalink": "string",
"excerpt": "string",
"inProgress": true,
"commentsCount": 0,
"contributors": [
"string"
]
},
"categories": "List<#CategoryVo>",
"tags": "List<#TagVo>",
"contributors": [
{
"name": "string",
"displayName": "string",
"avatar": "string",
"bio": "string"
}
],
"owner": {
"name": "string",
"displayName": "string",
"avatar": "string",
"bio": "string"
},
"stats": {
"visit": 0,
"upvote": 0,
"comment": 0
}
}
ListResult<ListedPostVo>
ListResult<ListedPostVo>
{
"page": 0,
"size": 0,
"total": 0,
"items": "List<#ListedPostVo>",
"first": true,
"last": true,
"hasNext": true,
"hasPrevious": true,
"totalPages": 0
}
PostArchiveVo
PostArchiveVo
{
"year": "string",
"months": [
{
"month": "string",
"posts": "#ListedPostVo"
}
]
}
ListResult<PostArchiveVo>
ListResult<PostArchiveVo>
{
"page": 0,
"size": 0,
"total": 0,
"items": "List<#PostArchiveVo>",
"first": true,
"last": true,
"hasNext": true,
"hasPrevious": true,
"totalPages": 0
}