Files
docs/versioned_docs/version-2.16/developer-guide/theme/global-variables.md
Ryan Wang de60c8a3fd chore: improve importing markdown file name (#368)
为被导入的 Markdown 片段文件名添加 `_`,防止为其生成页面。比如:https://docs.halo.run/developer-guide/theme/vo/ThemeVo

参考文档:https://docusaurus.io/docs/2.x/markdown-features/react#importing-markdown

/kind improvement

```release-note
None
```
2024-06-03 06:35:44 +00:00

1.1 KiB
Raw Blame History

title, description
title description
全局变量 本文档介绍 Halo 为模板引擎提供的专有全局变量。

import SiteSettingVo from "./vo/_SiteSettingVo.md" import ThemeVo from "./vo/_ThemeVo.md"

Halo 目前为模板引擎在全局提供了一些变量,本文档将列出已提供的变量以及介绍这些变量的使用方法。

site

描述

提供了部分可公开的系统相关的设置项,其中所有参数均来自于 Console 的系统设置。

类型

示例

显示站点标题:

<h1 th:text="${site.title}"></h1>

显示站点 Logo

<img th:src="${site.logo}" alt="Logo" />

theme

描述

关于当前激活主题的信息。

类型

示例

显示主题名称:

<h1 th:text="${theme.spec.displayName}"></h1>

在静态资源加入版本号参数,以防止升级之后的缓存问题:

<link rel="stylesheet" th:href="@{/assets/dist/style.css?v={version}(version=${theme.spec.version})}" />
<script th:src="@{/assets/dist/main.iife.js?v={version}(version=${theme.spec.version})}"></script>