mirror of
https://github.com/halo-dev/docs.git
synced 2025-10-21 18:24:58 +00:00

完善 Halo 2.0 主题开发的文档。 /kind documentation Fixes https://github.com/halo-dev/docs/issues/109 TODO list: - [x] 准备工作 - 提供从搭建 Halo 开发环境到成功应用一个新的主题的过程。 - [x] 目录结构 - 详细解释一个主题的目录构成,包括每一个目录和文件的作用。 - [x] 配置文件 - 提供 `theme.yaml` 的各个配置的解释。 - [x] 设置选项 - 讲解如何在主题模板中使用主题定义的 `settings.yaml` 配置项。**注意:关于 settings.yaml 或许可以单独出一篇文档,因为插件也需要用到。主题和插件的文档只需要单独讲解如何使用** - [x] 静态资源 - 讲解静态资源的引用。 - [x] 核心路由 - 列出 Halo 核心提供的路由以及模板,其中需要包括 `文章/自定义页面/分类的自定义模板` 的讲解 - [x] 模板变量 - 讲解系统内提供的路由对应模板中包含的变量。 - [x] Finder APIs - 讲解数据获取 API 的使用。 - [x] 常用代码片段 - 提供一些在主题开发中常用的代码片段,比如如何定义一个 `layout.html`,如何结构化渲染一个菜单或者文章分类等。 ```release-note None ```
3.8 KiB
3.8 KiB
title, description
title | description |
---|---|
分类归档 | category.html - /categories/:slug |
路由信息
- 模板路径:
/templates/category.html
- 访问路径:
/categories/:slug
变量
category
变量类型
posts
变量类型
#UrlContextListResult<ListedPostVo>
示例
<div>
<h1 th:text="${category.spec.displayName}"></h1>
<ul>
<li th:each="post : ${posts.items}">
<a
th:text="${post.spec.title}"
th:href="${post.status.permalink}"
></a>
</li>
</ul>
<div th:if="${posts.hasPrevious() || posts.hasNext()}">
<a
th:href="@{${posts.prevUrl}}"
>
<span>上一页</span>
</a>
<span th:text="${posts.page} +' / '+ ${posts.total}"></span>
<a
th:href="@{${posts.nextUrl}}"
>
<span>下一页</span>
</a>
</div>
</div>
_templateId
变量值
category
类型定义
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
{
"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
}
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
}
}
UrlContextListResult<ListedPostVo>
{
"page": 0,
"size": 0,
"total": 0,
"items": "List<#ListedPostVo>",
"first": true,
"last": true,
"hasNext": true,
"hasPrevious": true,
"totalPages": 0,
"nextUrl": "string",
"prevUrl": "string"
}