docs: update documentations for 2.22 (#537)

Signed-off-by: Ryan Wang <i@ryanc.cc>
This commit is contained in:
Ryan Wang
2025-12-24 11:31:37 +08:00
committed by GitHub
parent 8642b4e257
commit 5953f17ed2
203 changed files with 20185 additions and 34 deletions

View File

@@ -0,0 +1,224 @@
---
title: 文章分类
description: 文章分类 - CategoryFinder
---
import CategoryVo from "../vo/_CategoryVo.md"
import CategoryTreeVo from "../vo/_CategoryTreeVo.md"
## getByName(name)
```js
categoryFinder.getByName(name)
```
:::info 提示
通常建议配合 [主题设置](../settings.md) 和 [分类选择器](../../form-schema.md#categoryselect) 使用,让用户自行选择所需的分类。
:::
### 描述
根据 `metadata.name` 获取文章分类。
### 参数
1. `name:string` - 分类的唯一标识 `metadata.name`
### 返回值
[#CategoryVo](#categoryvo)
### 示例
```html
<div th:with="category = ${categoryFinder.getByName('category-foo')}">
<a th:href="@{${category.status.permalink}}" th:text="${category.spec.displayName}"></a>
</div>
```
## getByNames(names)
```js
categoryFinder.getByNames(names)
```
:::info 提示
通常建议配合 [主题设置](../settings.md) 和 [分类选择器](../../form-schema.md#categoryselect) 使用,让用户自行选择所需的分类。
:::
### 描述
根据一组 `metadata.name` 获取文章分类。
### 参数
1. `names:List<string>` - 分类的唯一标识 `metadata.name` 的集合。
### 返回值
List\<[#CategoryVo](#categoryvo)\>
### 示例
```html
<div th:with="categories = ${categoryFinder.getByNames({'category-foo', 'category-bar'})}">
<a th:each="category : ${categories}" th:href="@{${category.status.permalink}}" th:text="${category.spec.displayName}"></a>
</div>
```
## list(page,size)
```js
categoryFinder.list(page,size)
```
### 描述
根据分页参数获取分类列表。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
### 返回值
[#ListResult\<CategoryVo\>](#listresultcategoryvo)
### 示例
```html
<ul th:with="categories = ${categoryFinder.list(1,10)}">
<li th:each="category : ${categories.items}">
<a th:href="@{${category.status.permalink}}" th:text="${category.spec.displayName}"></a>
</li>
</ul>
```
## listAll()
```js
categoryFinder.listAll()
```
### 描述
获取所有文章分类。
### 参数
### 返回值
List\<[#CategoryVo](#categoryvo)\>
### 示例
```html
<ul th:with="categories = ${categoryFinder.listAll()}">
<li th:each="category : ${categories}">
<a th:href="@{${category.status.permalink}}" th:text="${category.spec.displayName}"></a>
</li>
</ul>
```
## listAsTree()
```js
categoryFinder.listAsTree()
```
### 描述
获取所有文章分类的多层级结构。
### 参数
### 返回值
List\<[#CategoryTreeVo](#categorytreevo)\>
### 示例
```html
<div th:with="categories = ${categoryFinder.listAsTree()}">
<ul>
<li th:replace="~{modules/category-tree :: single(categories=${categories})}" />
</ul>
</div>
```
```html title="/templates/category-tree.html"
<ul th:fragment="next (categories)">
<li th:fragment="single (categories)" th:each="category : ${categories}">
<a th:href="@{${category.status.permalink}}">
<span th:text="${category.spec.displayName}"> </span>
</a>
<th:block th:if="${not #lists.isEmpty(category.children)}">
<th:block th:replace="~{modules/category-tree :: next (categories=${category.children})}"></th:block>
</th:block>
</li>
</ul>
```
## getBreadcrumbs(name)
```js
categoryFinder.getBreadcrumbs('category-foo')
```
### 描述
获取分类树结构的路径节点,可以通过此方法来构建面包屑导航。
### 参数
- `name:string` - 分类的唯一标识 `metadata.name`,必填。
### 返回值
List\<[#CategoryVo](#categoryvo)\>
### 示例
```html
<div>
<th:block th:each="category,stats : ${categoryFinder.getBreadcrumbs(category.metadata?.name)}">
<a th:href="@{${category.status.permalink}}" th:text="${category.spec.displayName}"></a>
<span th:if="${!stats.last}">/</span>
</th:block>
</div>
```
## 类型定义
### CategoryVo
<CategoryVo />
### ListResult\<CategoryVo\>
```json title="ListResult<CategoryVo>"
{
"page": 0, // 当前页码
"size": 0, // 每页条数
"total": 0, // 总条数
"items": "List<#CategoryVo>", // 分类列表数据
"first": true, // 是否为第一页
"last": true, // 是否为最后一页
"hasNext": true, // 是否有下一页
"hasPrevious": true, // 是否有上一页
"totalPages": 0 // 总页数
}
```
- [#CategoryVo](#categoryvo)
### CategoryTreeVo
<CategoryTreeVo />
- [#CategoryTreeVo](#categorytreevo)

View File

@@ -0,0 +1,155 @@
---
title: 评论
description: 评论 - CommentFinder
---
import CommentVo from "../vo/_CommentVo.md"
import ReplyVo from "../vo/_ReplyVo.md"
## getByName(name)
```js
commentFinder.getByName(name)
```
### 描述
根据 `metadata.name` 获取评论。
### 参数
1. `name:string` - 评论的唯一标识 `metadata.name`
### 返回值
[#CommentVo](#commentvo)
### 示例
```html
<div th:with="comment = ${commentFinder.getByName('comment-foo')}">
<span th:text="${comment.spec.owner.displayName}"></span>
<div th:text="${comment.spec.content}"></div>
</div>
```
## list(ref,page,size)
```js
commentFinder.list(ref,page,size)
```
### 描述
根据评论的 `metadata.name` 和分页参数获取回复列表。
### 参数
1. `ref:#Ref` - 评论的唯一标识 `metadata.name`
2. `page:int` - 分页页码,从 1 开始
3. `size:int` - 分页条数
- [#Ref](#ref)
### 返回值
[#ListResult\<CommentVo\>](#listresultcommentvo)
### 示例
```html
<ul th:with="comments = ${commentFinder.list({ group: 'content.halo.run', version: 'v1alpha1', kind: 'Post', name: 'post-foo' },1,10)}">
<li th:each="comment : ${comments.items}">
<span th:text="${comment.spec.owner.displayName}"></span>
<div th:text="${comment.spec.content}"></div>
</li>
</ul>
```
## listReply(commentName,page,size)
```js
commentFinder.listReply(commentName,page,size)
```
### 描述
根据评论的 `metadata.name` 和分页参数获取回复列表。
### 参数
1. `commentName:string` - 评论的唯一标识 `metadata.name`
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
### 返回值
[#ListResult\<ReplyVo\>](#listresultreplyvo)
### 示例
```html
<ul th:with="replies = ${commentFinder.listReply('comment-foo',1,10)}">
<li th:each="reply : ${replies.items}">
<span th:text="${reply.spec.owner.displayName}"></span>
<div th:text="${reply.spec.content}"></div>
</li>
</ul>
```
## 类型定义
### CommentVo
<CommentVo />
### ListResult\<CommentVo\>
```json title="ListResult<CommentVo>"
{
"page": 0, // 当前页码
"size": 0, // 每页条数
"total": 0, // 总条数
"items": "List<#CommentVo>", // 评论列表数据
"first": true, // 是否为第一页
"last": true, // 是否为最后一页
"hasNext": true, // 是否有下一页
"hasPrevious": true, // 是否有上一页
"totalPages": 0 // 总页数
}
```
- [#CommentVo](#commentvo)
### ReplyVo
<ReplyVo />
### ListResult\<ReplyVo\>
```json title="ListResult<ReplyVo>"
{
"page": 0, // 当前页码
"size": 0, // 每页条数
"total": 0, // 总条数
"items": "List<#ReplyVo>", // 回复列表数据
"first": true, // 是否为第一页
"last": true, // 是否为最后一页
"hasNext": true, // 是否有下一页
"hasPrevious": true, // 是否有上一页
"totalPages": 0 // 总页数
}
```
- [#ReplyVo](#replyvo)
### Ref
```json title="Ref"
{
"group": "string",
"kind": "string",
"version": "string",
"name": "string"
}
```

View File

@@ -0,0 +1,64 @@
---
title: 作者
description: 作者 - ContributorFinder
---
import ContributorVo from "../vo/_ContributorVo.md"
## getContributor(name)
```js
contributorFinder.getContributor(name)
```
### 描述
根据 `metadata.name` 获取作者。
### 参数
1. `name:string` - 作者的唯一标识 `metadata.name`
### 返回值
[#ContributorVo](#contributorvo)
### 示例
```html
<div th:with="contributor = ${contributorFinder.getContributor('contributor-foo')}">
<h1 th:text="${contributor.displayName}"></h1>
</div>
```
## getContributors(names)
```js
contributorFinder.getContributors(names)
```
### 描述
根据一组 `metadata.name` 获取作者。
### 参数
1. `names:List<string>` - 作者的唯一标识 `metadata.name` 的集合。
### 返回值
List\<[#ContributorVo](#contributorvo)\>
### 示例
```html
<div th:with="contributors = ${contributorFinder.getContributors({'contributor-foo, 'contributor-bar'})}">
<span th:each="contributor : ${contributors}" th:text="${contributor.displayName}"></span>
</div>
```
## 类型定义
### ContributorVo
<ContributorVo />

View File

@@ -0,0 +1,87 @@
---
title: 导航菜单
description: 导航菜单 - MenuFinder
---
import MenuItemVo from "../vo/_MenuItemVo.md"
import MenuVo from "../vo/_MenuVo.md"
## getByName(name)
```js
menuFinder.getByName(name)
```
### 描述
根据 `metadata.name` 获取菜单。
### 参数
1. `name:string` - 菜单的唯一标识 `metadata.name`
### 返回值
[#MenuVo](#menuvo)
### 示例
```html
<div th:with="menu = ${menuFinder.getByName('menu-foo')}">
<ul th:with="menuItems = ${menu.menuItems}">
<li th:each="menuItem : ${menuItems}">
<a
th:href="@{${menuItem.status.href}}"
th:text="${menuItem.status.displayName}"
th:target="${menuItem.spec.target?.value}"
>
</a>
</li>
</ul>
</div>
```
## getPrimary()
```js
menuFinder.getPrimary()
```
### 描述
获取主菜单。
### 参数
### 返回值
[#MenuVo](#menuvo)
### 示例
```html
<div th:with="menu = ${menuFinder.getPrimary()}">
<ul th:with="menuItems = ${menu.menuItems}">
<li th:each="menuItem : ${menuItems}">
<a
th:href="@{${menuItem.status.href}}"
th:text="${menuItem.status.displayName}"
th:target="${menuItem.spec.target?.value}"
>
</a>
</li>
</ul>
</div>
```
## 类型定义
### MenuVo
<MenuVo />
### MenuItemVo
<MenuItemVo />

View File

@@ -0,0 +1,63 @@
---
title: 插件
description: 插件 - PluginFinder
---
## available(pluginName)
```js
pluginFinder.available(pluginName)
```
### 描述
判断一个插件是否可用,会同时判断插件是否安装和启用。
### 参数
1. `pluginName:string` - 插件的唯一标识 `metadata.name`
### 返回值
`boolean` - 插件是否可用
### 示例
```html
<!-- https://github.com/halo-sigs/plugin-search-widget -->
<li th:if="${pluginFinder.available('PluginSearchWidget')}">
<a href="javascript:SearchWidget.open()" title="搜索">
搜索
</a>
</li>
```
## available(pluginName, requiresVersion)
```js
pluginFinder.available('fake-plugin', '>=2.3.0')
```
### 描述
判断一个插件是否可用,会同时判断插件是否安装和启用且插件的版本符合 `requiresVersion` 要求,
### 参数
1. `pluginName:string` - 插件的唯一标识 `metadata.name`,不能为空。
2. `requiresVersion:string` - 插件的版本要求,不能为空,例如:`>1.2.0``requiresVersion` 的格式遵循 [Semantic Range Expressions](https://github.com/zafarkhaja/jsemver#range-expressions)。
### 返回值
`boolean` - 插件是否可用
### 示例
```html
<!-- https://github.com/halo-sigs/plugin-search-widget -->
<li th:if="${pluginFinder.available('PluginSearchWidget', '>=2.3.0')}">
<a href="javascript:SearchWidget.open()" title="搜索">
搜索
</a>
</li>
```

View File

@@ -0,0 +1,520 @@
---
title: 文章
description: 文章 - PostFinder
---
import CategoryVo from "../vo/_CategoryVo.md";
import TagVo from "../vo/_TagVo.md";
import PostVo from "../vo/_PostVo.md";
import ContentVo from "../vo/_ContentVo.md"
import ContributorVo from "../vo/_ContributorVo.md"
import ListedPostVo from "../vo/_ListedPostVo.md"
## getByName(postName)
```js
postFinder.getByName(postName);
```
### 描述
根据 `metadata.name` 获取文章。
### 参数
1. `postName:string` - 文章的唯一标识 `metadata.name`
### 返回值
[#PostVo](#postvo)
### 示例
```html
<div th:with="post = ${postFinder.getByName('post-foo')}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}"></a>
</div>
```
## content(postName)
```js
postFinder.content(postName);
```
### 描述
根据文章的 `metadata.name` 单独获取文章内容。
### 参数
1. `postName:string` - 文章的唯一标识 `metadata.name`
### 返回值
[#ContentVo](#contentvo)
### 示例
```html
<div th:with="content = ${postFinder.content('post-foo')}">
<div th:utext="${content.content}"></div>
</div>
```
## cursor(postName)
```js
postFinder.cursor(postName);
```
### 描述
根据文章的 `metadata.name` 获取相邻的文章(上一篇 / 下一篇)。
:::info 提示
上一篇文章是指发布时间较当前文章更早的文章,下一篇文章是指发布时间较当前文章更新的文章。
:::
### 参数
1. `postName:string` - 文章的唯一标识 `metadata.name`
### 返回值
[#NavigationPostVo](#navigationpostvo)
### 示例
```html title="/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()
```js
postFinder.listAll();
```
### 描述
获取所有文章。
### 参数
### 返回值
List\<[#ListedPostVo](#listedpostvo)\>
### 示例
```html
<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({...})`
```js
postFinder.list({
page: 1,
size: 10,
tagName: 'fake-tag',
categoryName: 'fake-category',
ownerName: 'fake-owner',
sort: {'spec.publishTime,desc', 'metadata.creationTimestamp,asc'}
});
```
### 描述
统一参数的文章列表查询方法,支持分页、标签、分类、创建者、排序等参数,且均为可选参数。
可以使用此方法来代替 `list(page, size)`、`listByCategory(page, size, categoryName)`、`listByTag(page, size, tag)`、`listByOwner(page, size, owner)` 方法。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
3. `tagName:string` - 标签唯一标识 `metadata.name`
4. `categoryName:string` - 分类唯一标识 `metadata.name`
5. `ownerName:string` - 创建者用户名 `name`
6. `sort:string[]` - 排序字段,格式为 `字段名,排序方式`,排序方式可选值为 `asc` 或 `desc`,如 `spec.publishTime,desc`,传递时需要使用 `{}` 形式并用逗号分隔表示数组。
### 返回值
[#ListResult\<ListedPostVo\>](#listresultlistedpostvo)
### 示例
```html
<ul th:with="posts = ${postFinder.list({
page: 1,
size: 10,
tagName: 'fake-tag',
categoryName: 'fake-category',
ownerName: 'fake-owner',
sort: {'spec.publishTime,desc', 'metadata.creationTimestamp,asc'}
})}">
<li th:each="post : ${posts.items}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}"></a>
</li>
</ul>
```
## list(page,size)
```js
postFinder.list(page, size);
```
### 描述
根据分页参数获取文章列表。
**已过时**: 请使用 `list({...})` 方法代替。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
### 返回值
[#ListResult\<ListedPostVo\>](#listresultlistedpostvo)
### 示例
```html
<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)
```js
postFinder.listByCategory(page, size, categoryName);
```
### 描述
根据分类标识和分页参数获取文章列表。
**已过时**: 请使用 `list({...})` 方法代替。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
3. `categoryName:string` - 文章分类唯一标识 `metadata.name`
### 返回值
[#ListResult\<ListedPostVo\>](#listresultlistedpostvo)
### 示例
```html
<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)
```js
postFinder.listByTag(page, size, tag);
```
### 描述
根据标签标识和分页参数获取文章列表。
**已过时**: 请使用 `list({...})` 方法代替。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
3. `tag:string` - 文章分类唯一标识 `metadata.name`
### 返回值
[#ListResult\<ListedPostVo\>](#listresultlistedpostvo)
### 示例
```html
<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>
```
## listByOwner(page,size,owner)
```js
postFinder.listByOwner(page, size, owner);
```
### 描述
根据创建者用户名和分页参数获取文章列表。
**已过时**: 请使用 `list({...})` 方法代替。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
3. `owner:string` - 创建者用户名 `name`
### 返回值
[#ListResult\<ListedPostVo\>](#listresultlistedpostvo)
### 示例
```html
<ul th:with="posts = ${postFinder.listByOwner(1,10,'admin')}">
<li th:each="post : ${posts.items}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}"></a>
</li>
</ul>
```
## archives(page,size)
```js
postFinder.archives(page, size);
```
### 描述
根据分页参数获取文章归档列表。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
### 返回值
[#ListResult\<PostArchiveVo\>](#listresultpostarchivevo)
### 示例
```html
<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)
```js
postFinder.archives(page, size, year);
```
### 描述
根据年份和分页参数获取文章归档列表。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
3. `year:string` - 年份
### 返回值
[#ListResult\<PostArchiveVo\>](#listresultpostarchivevo)
### 示例
```html
<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)
```js
postFinder.archives(page, size, year, month);
```
### 描述
根据年月和分页参数获取文章归档列表。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
3. `year:string` - 年份
4. `month:string` - 月份
### 返回值
[#ListResult\<PostArchiveVo\>](#listresultpostarchivevo)
### 示例
```html
<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 />
### TagVo
<TagVo />
### ContributorVo
<ContributorVo />
### PostVo
<PostVo />
- [#CategoryVo](#categoryvo)
- [#TagVo](#tagvo)
- [#ContributorVo](#contributorvo)
- [#ContentVo](#contentvo)
### ContentVo
<ContentVo />
### NavigationPostVo
```json title="NavigationPostVo"
{
"previous": "#ListedPostVo", // 上一篇文章,发布时间较当前文章更早的文章
"next": "#ListedPostVo" // 下一篇文章,发布时间较当前文章更新的文章
}
```
- [#PostVo](#postvo)
### ListedPostVo
<ListedPostVo />
- [#CategoryVo](#categoryvo)
- [#TagVo](#tagvo)
- [#ContributorVo](#contributorvo)
### ListResult\<ListedPostVo\>
```json title="ListResult<ListedPostVo>"
{
"page": 0, // 当前页码
"size": 0, // 每页条数
"total": 0, // 总条数
"items": "List<#ListedPostVo>", // 文章列表数据
"first": true, // 是否为第一页
"last": true, // 是否为最后一页
"hasNext": true, // 是否有下一页
"hasPrevious": true, // 是否有上一页
"totalPages": 0 // 总页数
}
```
- [#ListedPostVo](#listedpostvo)
### PostArchiveVo
```json title="PostArchiveVo"
{
"year": "string",
"months": [
{
"month": "string",
"posts": "#ListedPostVo"
}
]
}
```
- [#ListedPostVo](#listedpostvo)
### ListResult\<PostArchiveVo\>
```json title="ListResult<PostArchiveVo>"
{
"page": 0, // 当前页码
"size": 0, // 每页条数
"total": 0, // 总条数
"items": "List<#PostArchiveVo>", // 文章归档数据
"first": true, // 是否为第一页
"last": true, // 是否为最后一页
"hasNext": true, // 是否有下一页
"hasPrevious": true, // 是否有上一页
"totalPages": 0 // 总页数
}
```
- [#PostArchiveVo](#postarchivevo)

View File

@@ -0,0 +1,131 @@
---
title: 独立页面
description: 独立页面 - SinglePageFinder
---
import SinglePageVo from "../vo/_SinglePageVo.md"
import ListedSinglePageVo from "../vo/_ListedSinglePageVo.md"
import ContributorVo from "../vo/_ContributorVo.md"
import ContentVo from "../vo/_ContentVo.md"
## getByName(pageName)
```js
singlePageFinder.getByName(pageName)
```
### 描述
根据 `metadata.name` 获取独立页面。
### 参数
1. `pageName:string` - 独立页面的唯一标识 `metadata.name`
### 返回值
[#SinglePageVo](#singlepagevo)
### 示例
```html
<div th:with="singlePage = ${singlePageFinder.getByName('page-foo')}">
<a th:href="@{${singlePage.status.permalink}}" th:text="${singlePage.spec.title}"></a>
</div>
```
## content(pageName)
```js
singlePageFinder.content(pageName)
```
### 描述
根据独立页面的 `metadata.name` 单独获取独立页面内容。
### 参数
1. `pageName:string` - 独立页面的唯一标识 `metadata.name`
### 返回值
[#ContentVo](#contentvo)
### 示例
```html
<div th:with="content = ${singlePageFinder.content('page-foo')}">
<div th:utext="${content.content}"></div>
</div>
```
## list(page,size)
```js
singlePageFinder.list(page,size)
```
### 描述
根据分页参数获取独立页面列表。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
### 返回值
[#ListResult\<ListedSinglePageVo\>](#listresultlistedsinglepagevo)
### 示例
```html
<ul th:with="singlePages = ${singlePageFinder.list(1,10)}">
<li th:each="singlePage : ${singlePages.items}">
<a th:href="@{${singlePage.status.permalink}}" th:text="${singlePage.spec.title}"></a>
</li>
</ul>
```
## 类型定义
### SinglePageVo
<SinglePageVo />
- [#ContributorVo](#contributorvo)
- [#ContentVo](#contentvo)
### ListedSinglePageVo
- [#ContributorVo](#contributorvo)
<ListedSinglePageVo />
### ListResult\<ListedSinglePageVo\>
```json title="ListResult<ListedSinglePageVo>"
{
"page": 0, // 当前页码
"size": 0, // 每页条数
"total": 0, // 总条数
"items": "List<#ListedSinglePageVo>", // 自定义页面列表数据
"first": true, // 是否为第一页
"last": true, // 是否为最后一页
"hasNext": true, // 是否有下一页
"hasPrevious": true, // 是否有上一页
"totalPages": 0 // 总页数
}
```
- [#ListedSinglePageVo](#listedsinglepagevo)
### ContentVo
<ContentVo />
### ContributorVo
<ContributorVo />

View File

@@ -0,0 +1,45 @@
---
title: 站点统计
description: 站点统计 - SiteStatsFinder
---
## getStats()
```js
siteStatsFinder.getStats()
```
### 描述
获取站点的统计信息。
### 参数
### 返回值
[#SiteStatsVo](#sitestatsvo)
### 示例
```html
<ul th:with="stats = ${siteStatsFinder.getStats()}">
<li th:text="${stats.visit}"></li>
<li th:text="${stats.post}"></li>
</ul>
```
## 类型定义
### SiteStatsVo
```json title="SiteStatsVo"
{
"visit": 0, // 访问数量
"upvote": 0, // 点赞数量
"comment": 0, // 评论数量
"post": 0, // 文章数量
"category": 0 // 分类数量
}
```

View File

@@ -0,0 +1,147 @@
---
title: 文章标签
description: 文章标签 - TagFinder
---
import TagVo from "../vo/_TagVo.md"
## getByName(name)
```js
tagFinder.getByName(name)
```
:::info 提示
通常建议配合 [主题设置](../settings.md) 和 [标签选择器](../../form-schema.md#tagselect) 使用,让用户自行选择所需的标签。
:::
### 描述
根据 `metadata.name` 获取标签。
### 参数
1. `name:string` - 标签的唯一标识 `metadata.name`
### 返回值
[#TagVo](#tagvo)
### 示例
```html
<div th:with="tag = ${tagFinder.getByName('tag-foo')}">
<a th:href="@{${tag.status.permalink}}" th:text="${tag.spec.displayName}"></a>
</div>
```
## getByNames(names)
```js
tagFinder.getByNames(names)
```
:::info 提示
通常建议配合 [主题设置](../settings.md) 和 [标签选择器](../../form-schema.md#tagselect) 使用,让用户自行选择所需的标签。
:::
### 描述
根据一组 `metadata.name` 获取标签。
### 参数
1. `names:List<string>` - 标签的唯一标识 `metadata.name` 的集合。
### 返回值
List\<[#TagVo](#tagvo)\>
### 示例
```html
<div th:with="tags = ${tagFinder.getByNames({'tag-foo', 'tag-bar'})}">
<a th:each="tag : ${tags}" th:href="@{${tag.status.permalink}}" th:text="${tag.spec.displayName}"></a>
</div>
```
## list(page,size)
```js
tagFinder.list(page,size)
```
### 描述
根据分页参数获取标签列表。
### 参数
1. `page:int` - 分页页码,从 1 开始
2. `size:int` - 分页条数
### 返回值
[#ListResult\<TagVo\>](#listresulttagvo)
### 示例
```html
<ul th:with="tags = ${tagFinder.list(1,10)}">
<li th:each="tag : ${tags.items}">
<a th:href="@{${tag.status.permalink}}" th:text="${tag.spec.displayName}"></a>
</li>
</ul>
```
## listAll()
```js
tagFinder.listAll()
```
### 描述
获取所有文章标签。
### 参数
### 返回值
List\<[#TagVo](#tagvo)\>
### 示例
```html
<ul th:with="tags = ${tagFinder.listAll()}">
<li th:each="tag : ${tags}">
<a th:href="@{${tag.status.permalink}}" th:text="${tag.spec.displayName}"></a>
</li>
</ul>
```
## 类型定义
### TagVo
<TagVo />
### ListResult\<TagVo\>
```json title="ListResult<TagVo>"
{
"page": 0, // 当前页码
"size": 0, // 每页条数
"total": 0, // 总条数
"items": "List<#TagVo>", // 标签列表数据
"first": true, // 是否为第一页
"last": true, // 是否为最后一页
"hasNext": true, // 是否有下一页
"hasPrevious": true, // 是否有上一页
"totalPages": 0 // 总页数
}
```
- [#TagVo](#tagvo)

View File

@@ -0,0 +1,119 @@
---
title: 主题
description: 主题 - ThemeFinder
---
## activation()
```js
themeFinder.activation()
```
### 描述
获取当前激活的主题。
### 参数
### 返回值
[#ThemeVo](#themevo)
### 示例
```html
<div th:with="theme = ${themeFinder.activation()}">
<h1 th:text="${theme.spec.displayName}"></h1>
<p th:text="${theme.spec.version}"></p>
</div>
```
## getByName(themeName)
```js
themeFinder.getByName(themeName)
```
### 描述
根据主题的唯一标识 `metadata.name` 获取主题。
### 参数
- `themeName:string` - 主题名称
### 返回值
[#ThemeVo](#themevo)
### 示例
```html
<div th:with="theme = ${themeFinder.getByName('theme-foo')}">
<h1 th:text="${theme.spec.displayName}"></h1>
<p th:text="${theme.spec.version}"></p>
</div>
```
## 类型定义
### ThemeVo
```json title="ThemeVo"
{
"metadata": {
"name": "string", // 唯一标识
"labels": {
"additionalProp1": "string"
},
"annotations": {
"additionalProp1": "string"
},
"creationTimestamp": "2022-11-20T15:27:15.036Z", // 创建时间
},
"spec": {
"displayName": "string", // 显示名称
"author": {
"name": "string", // 作者名称
"website": "string" // 作者网站
},
"description": "string", // 描述
"logo": "string", // Logo
"website": "string", // 网站
"repo": "string", // 仓库地址
"version": "string", // 版本
"require": "string", // 依赖 Halo 的版本
"settingName": "string", // 表单定义的名称,即 Setting 资源的 metadata.name
"configMapName": "string", // 设置项存储的名称,即 ConfigMap 资源的 metadata.name
"customTemplates": {
"post": [
{
"name": "string",
"description": "string",
"screenshot": "string",
"file": "string"
}
],
"category": [
{
"name": "string",
"description": "string",
"screenshot": "string",
"file": "string"
}
],
"page": [
{
"name": "string",
"description": "string",
"screenshot": "string",
"file": "string"
}
]
}
},
"config": {}
}
```