docs: add the way to get the category tree in the theme development documentation (#37)

Signed-off-by: Ryan Wang <i@ryanc.cc>
JohnNiang-patch-1
Ryan Wang 3 years ago committed by GitHub
parent 002bdf3704
commit 7993abe690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -996,6 +996,108 @@ categories:
<a href="http://localhost:8090/categories/url2">name212</a>
```
### 获取分类目录树结构tree
#### 语法
```html
<@categoryTag method="tree">
// do something
</@categoryTag>
```
参数:
1. methodtree
#### 返回参数
categories:
```json
[
{
"children": [
{
"children": [],
"createTime": "2022-02-12T14:11:06.376Z",
"description": "string",
"fullPath": "string",
"id": 0,
"name": "string",
"parentId": 0,
"password": "string",
"slug": "string",
"thumbnail": "string"
}
],
"createTime": "2022-02-12T14:11:06.376Z",
"description": "string",
"fullPath": "string",
"id": 0,
"name": "string",
"parentId": 0,
"password": "string",
"slug": "string",
"thumbnail": "string"
}
]
```
#### 示例
```html
<@categoryTag method="tree">
<ul>
<#list categories as category>
<li>
<a href="${category.fullPath!}">
${category.name!}
</a>
</li>
<#if category.children?? && category.children?size gt 0>
<@renderCategories category.children></@renderCategories>
</#if>
</#list>
</ul>
</@categoryTag>
<#macro renderCategories categories>
<ul>
<#list categories as category>
<li>
<a href="${category.fullPath!}">
${(category.name)!}
</a>
<#if category.children?? && category.children?size gt 0>
<@renderCategories category.children></@renderCategories>
</#if>
</li>
</#list>
</ul>
</#macro>
```
输出:
```html
<ul>
<li>
<a href="http://localhost:8090/categories/parent">
父级分类
</a>
</li>
<ul>
<li>
<a href="http://localhost:8090/categories/child">
子分类
</a>
</li>
</ul>
</ul>
```
### 获取文章的所有分类listByPostId
#### 语法

@ -996,6 +996,108 @@ categories:
<a href="http://localhost:8090/categories/url2">name212</a>
```
### 获取分类目录树结构tree
#### 语法
```html
<@categoryTag method="tree">
// do something
</@categoryTag>
```
参数:
1. methodtree
#### 返回参数
categories:
```json
[
{
"children": [
{
"children": [],
"createTime": "2022-02-12T14:11:06.376Z",
"description": "string",
"fullPath": "string",
"id": 0,
"name": "string",
"parentId": 0,
"password": "string",
"slug": "string",
"thumbnail": "string"
}
],
"createTime": "2022-02-12T14:11:06.376Z",
"description": "string",
"fullPath": "string",
"id": 0,
"name": "string",
"parentId": 0,
"password": "string",
"slug": "string",
"thumbnail": "string"
}
]
```
#### 示例
```html
<@categoryTag method="tree">
<ul>
<#list categories as category>
<li>
<a href="${category.fullPath!}">
${category.name!}
</a>
</li>
<#if category.children?? && category.children?size gt 0>
<@renderCategories category.children></@renderCategories>
</#if>
</#list>
</ul>
</@categoryTag>
<#macro renderCategories categories>
<ul>
<#list categories as category>
<li>
<a href="${category.fullPath!}">
${(category.name)!}
</a>
<#if category.children?? && category.children?size gt 0>
<@renderCategories category.children></@renderCategories>
</#if>
</li>
</#list>
</ul>
</#macro>
```
输出:
```html
<ul>
<li>
<a href="http://localhost:8090/categories/parent">
父级分类
</a>
</li>
<ul>
<li>
<a href="http://localhost:8090/categories/child">
子分类
</a>
</li>
</ul>
</ul>
```
### 获取文章的所有分类listByPostId
#### 语法
@ -1671,7 +1773,7 @@ teams:
<#list teams as team>
<h1>${team.team}</h1>
<ul>
<#list team.links as link>
<#list links as link>
<li>
<a href="${link.url!}" target="_blank">
${link.name!}
@ -1754,7 +1856,7 @@ teams:
<#list teams as team>
<h1>${team.team}</h1>
<ul>
<#list team.links as link>
<#list links as link>
<li>
<a href="${link.url!}" target="_blank">
${link.name!}
@ -2642,4 +2744,4 @@ pagination
<a href="http://localhost:8090/journals/page/3">下一页</a>
</li>
</ul>
```
```
Loading…
Cancel
Save