Files
docs/versioned_docs/version-2.20/developer-guide/theme/template-variables/post.md
Ryan Wang 22600b7f6f fix: missing example display for ListedPostVo type (#482)
修复 ListedPostVo 类型示例不显示的问题。

Fixes #480 

```release-note
None
```
2024-12-09 11:23:35 +00:00

1.9 KiB

title, description
title description
文章 post.html - /archives/:slug

import CategoryVo from "../vo/_CategoryVo.md" import TagVo from "../vo/_TagVo.md" import ContentVo from "../vo/_ContentVo.md" import ContributorVo from "../vo/_ContributorVo.md" import PostVo from "../vo/_PostVo.md"

文章详情页面的模板。

路由信息

  • 模板路径:/templates/post.html
  • 访问路径:默认为 /archives/:slug,用户可手动更改为其他路由形式,可参考:主题路由设置

自定义模板

除了上面提到的 post.html,主题作者还可以添加多种形式的额外渲染模板,提供给用户选择,此举可以丰富网站的使用类型,用户设置方式可参考 文章设置

定义方式为:

customTemplates:
  post:
    - name: {name}
      description: {description}
      screenshot: {screenshot}
      file: {file}.html
  • name:模板名称
  • description:模板描述
  • screenshot:模板预览图
  • file:模板文件名,需要在 /templates/ 目录下创建

示例:

customTemplates:
  post:
    - name: 文档
      description: 文档类型的文章
      screenshot: 
      file: post_documentation.html

:::info 需要注意,修改 theme.yaml 需要重载主题配置。 :::

变量

post

变量类型

#PostVo

示例

<article>
  <h1 th:text="${post.spec.title}"></h1>
  <div th:utext="${post.content.content}"> </div>
</article>

_templateId

变量值

post

类型定义

CategoryVo

TagVo

ContributorVo

ContentVo

PostVo