forked from drowl87/hextra_mirror
docs: update zh-cn translations
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
---
|
||||
linkTitle: 高级配置
|
||||
title: 高级配置
|
||||
linkTitle: 高级
|
||||
title: 高级主题
|
||||
prev: /docs/guide/shortcodes/tabs
|
||||
next: /docs/advanced/multi-language
|
||||
---
|
||||
|
||||
此部分提供了 Hextra 的一些高级配置。
|
||||
本节涵盖了一些主题的高级内容。
|
||||
|
||||
<!--more-->
|
||||
|
||||
{{< cards >}}
|
||||
{{< card link="multi-language" title="多语言" icon="translate" >}}
|
||||
{{< card link="customization" title="定制化" icon="pencil" >}}
|
||||
{{< /cards >}}
|
||||
{{< card link="customization" title="自定义" icon="pencil" >}}
|
||||
{{< card link="comments" title="评论系统" icon="chat-alt" >}}
|
||||
{{< /cards >}}
|
@ -1,18 +1,18 @@
|
||||
---
|
||||
title: 评论系统
|
||||
linkTitle: Comments
|
||||
linkTitle: 评论
|
||||
---
|
||||
|
||||
Hextra 支持在你的网站中添加评论系统。
|
||||
目前已经支持 [giscus](https://giscus.app/).
|
||||
Hextra 支持为您的网站添加评论系统。
|
||||
目前支持 [giscus](https://giscus.app/)。
|
||||
|
||||
<!--more-->
|
||||
|
||||
## giscus
|
||||
|
||||
[giscus](https://giscus.app/) 是由 [GitHub Discussions](https://docs.github.com/en/discussions)驱动的评论系统。Giscus 免费并且开源。
|
||||
[giscus](https://giscus.app/) 是一个由 [GitHub Discussions](https://docs.github.com/en/discussions) 提供支持的评论系统。它是免费且开源的。
|
||||
|
||||
如需启用 Giscus, 你需要在配置文件中添加以下内容:
|
||||
要启用 giscus,您需要在网站配置文件中添加以下内容:
|
||||
|
||||
```yaml {filename="hugo.yaml"}
|
||||
params:
|
||||
@ -21,19 +21,19 @@ params:
|
||||
type: giscus
|
||||
|
||||
giscus:
|
||||
repo: <repository>
|
||||
repoId: <repository ID>
|
||||
category: <category>
|
||||
categoryId: <category ID>
|
||||
repo: <仓库>
|
||||
repoId: <仓库 ID>
|
||||
category: <分类>
|
||||
categoryId: <分类 ID>
|
||||
```
|
||||
|
||||
Giscus 配置可以参考 [giscus.app](https://giscus.app/),还可以在那里找到更多详细信息。
|
||||
giscus 的配置可以从 [giscus.app](https://giscus.app/) 网站生成。更多详细信息也可以在那里找到。
|
||||
|
||||
可以在 front matter 中启用或禁用特定页面的评论:
|
||||
可以在页面的 front matter 中为特定页面启用或禁用评论:
|
||||
|
||||
```yaml {filename="content/docs/about.md"}
|
||||
---
|
||||
title: About
|
||||
title: 关于
|
||||
comments: true
|
||||
---
|
||||
```
|
||||
```
|
@ -3,14 +3,18 @@ title: 自定义 Hextra
|
||||
linkTitle: 自定义
|
||||
---
|
||||
|
||||
Hextra 在 `hugo.yaml` 中提供了一些自定义选项来配置主题。
|
||||
本页介绍了可用选项以及如何进一步自定义主题。
|
||||
Hextra 在 `hugo.yaml` 配置文件中提供了一些默认的自定义选项,用于配置主题。
|
||||
本页描述了可用的选项以及如何进一步自定义主题。
|
||||
|
||||
<!--more-->
|
||||
|
||||
## 自定义 CSS
|
||||
|
||||
要添加自定义 CSS,我们需要在站点中创建一个文件 `assets/css/custom.css`。Hextra 将自动加载该文件,比如自定义字体:
|
||||
要添加自定义 CSS,我们需要在站点中创建一个文件 `assets/css/custom.css`。Hextra 会自动加载此文件。
|
||||
|
||||
### 字体
|
||||
|
||||
内容的字体可以通过以下方式自定义:
|
||||
|
||||
```css {filename="assets/css/custom.css"}
|
||||
.content {
|
||||
@ -18,41 +22,190 @@ Hextra 在 `hugo.yaml` 中提供了一些自定义选项来配置主题。
|
||||
}
|
||||
```
|
||||
|
||||
### 主题色
|
||||
### 内联代码元素
|
||||
|
||||
主题色可以通过设置 `--primary-hue` 变量来自定义:
|
||||
与 `其他文本` 混合的文本颜色可以通过以下方式自定义:
|
||||
|
||||
```css {filename="assets/css/custom.css"}
|
||||
.content code:not(.code-block code) {
|
||||
color: #c97c2e;
|
||||
}
|
||||
```
|
||||
|
||||
### 主色调
|
||||
|
||||
主题的主色调可以通过设置 `--primary-hue`、`--primary-saturation` 和 `--primary-lightness` 变量来自定义:
|
||||
|
||||
```css {filename="assets/css/custom.css"}
|
||||
:root {
|
||||
--primary-hue: 100deg;
|
||||
--primary-saturation: 90%;
|
||||
--primary-lightness: 50%;
|
||||
}
|
||||
```
|
||||
|
||||
### 代码高亮
|
||||
### 进一步的主题自定义
|
||||
|
||||
代码高亮风格的详细信息可在 [Chroma Styles Gallery](https://xyproto.github.io/splash/docs/all.html) 中找到。可以使用以下命令生成样式表:
|
||||
可以通过覆盖暴露的 CSS 类来进一步自定义主题。以下是一个自定义页脚元素的示例:
|
||||
|
||||
```css {filename="assets/css/custom.css"}
|
||||
.hextra-footer {
|
||||
/* 样式将应用于页脚元素 */
|
||||
}
|
||||
|
||||
.hextra-footer:is(html[class~="dark"] *) {
|
||||
/* 样式将应用于暗模式下的页脚元素 */
|
||||
}
|
||||
```
|
||||
|
||||
以下类可用于自定义主题的各个部分。
|
||||
|
||||
#### 通用
|
||||
|
||||
- `hextra-scrollbar` - 滚动条元素
|
||||
- `content` - 页面内容容器
|
||||
|
||||
#### 短代码
|
||||
|
||||
##### 徽章
|
||||
|
||||
- `hextra-badge` - 徽章元素
|
||||
|
||||
##### 卡片
|
||||
|
||||
- `hextra-card` - 卡片元素
|
||||
- `hextra-card-image` - 卡片图片元素
|
||||
- `hextra-card-icon` - 卡片图标元素
|
||||
- `hextra-card-subtitle` - 卡片副标题元素
|
||||
|
||||
##### 卡片组
|
||||
|
||||
- `hextra-cards` - 卡片网格容器
|
||||
|
||||
##### Jupyter Notebook
|
||||
|
||||
- `hextra-jupyter-code-cell` - Jupyter 代码单元容器
|
||||
- `hextra-jupyter-code-cell-outputs-container` - Jupyter 代码单元输出容器
|
||||
- `hextra-jupyter-code-cell-outputs` - Jupyter 代码单元输出 div 元素
|
||||
|
||||
##### PDF
|
||||
|
||||
- `hextra-pdf` - PDF 容器元素
|
||||
|
||||
##### 步骤
|
||||
|
||||
- `steps` - 步骤容器
|
||||
|
||||
##### 标签页
|
||||
|
||||
- `hextra-tabs-panel` - 标签页面板容器
|
||||
- `hextra-tabs-toggle` - 标签页切换按钮
|
||||
|
||||
##### 文件树
|
||||
|
||||
- `hextra-filetree` - 文件树容器
|
||||
|
||||
##### 文件夹
|
||||
|
||||
- `hextra-filetree-folder` - 文件树文件夹容器
|
||||
|
||||
#### 导航栏
|
||||
|
||||
- `nav-container` - 导航栏容器
|
||||
- `nav-container-blur` - 导航栏模糊元素
|
||||
- `hamburger-menu` - 汉堡菜单按钮
|
||||
|
||||
#### 页脚
|
||||
|
||||
- `hextra-footer` - 页脚元素
|
||||
- `hextra-custom-footer` - 自定义页脚部分容器
|
||||
|
||||
#### 搜索
|
||||
|
||||
- `search-wrapper` - 搜索包装容器
|
||||
- `search-input` - 搜索输入元素
|
||||
- `search-results` - 搜索结果列表容器
|
||||
|
||||
#### 目录
|
||||
|
||||
- `hextra-toc` - 目录容器
|
||||
|
||||
#### 侧边栏
|
||||
|
||||
- `mobile-menu-overlay` - 移动菜单的覆盖元素
|
||||
- `sidebar-container` - 侧边栏容器
|
||||
- `sidebar-active-item` - 侧边栏中的活动项
|
||||
|
||||
#### 语言切换器
|
||||
|
||||
- `language-switcher` - 语言切换按钮
|
||||
- `language-options` - 语言选项容器
|
||||
|
||||
#### 主题切换
|
||||
|
||||
- `theme-toggle` - 主题切换按钮
|
||||
|
||||
#### 代码复制按钮
|
||||
|
||||
- `hextra-code-copy-btn-container` - 代码复制按钮容器
|
||||
- `hextra-code-copy-btn` - 代码复制按钮
|
||||
|
||||
#### 代码块
|
||||
|
||||
- `hextra-code-block` - 代码块容器
|
||||
|
||||
#### 功能卡片
|
||||
|
||||
- `hextra-feature-card` - 功能卡片链接元素
|
||||
|
||||
#### 功能网格
|
||||
|
||||
- `hextra-feature-grid` - 功能网格容器
|
||||
|
||||
#### 面包屑导航
|
||||
|
||||
面包屑导航没有特定的类。
|
||||
|
||||
### 语法高亮
|
||||
|
||||
可用的语法高亮主题列表可在 [Chroma 样式库](https://xyproto.github.io/splash/docs/all.html) 中找到。可以使用以下命令生成样式表:
|
||||
|
||||
```shell
|
||||
hugo gen chromastyles --style=github
|
||||
```
|
||||
|
||||
可将生成的样式添加到自定义 CSS 文件中以覆盖默认代码高亮样式。
|
||||
要覆盖默认的语法高亮主题,可以将生成的样式添加到自定义 CSS 文件中。
|
||||
|
||||
## 自定义 Script
|
||||
## 自定义脚本
|
||||
|
||||
你可以添加以下文件以自定义 `script` 添加到每页的 `head` 最后:
|
||||
你可以通过添加以下文件在每个页面的 head 末尾添加自定义脚本:
|
||||
|
||||
```
|
||||
layouts/partials/custom/head-end.html
|
||||
```
|
||||
|
||||
## 自定义页脚额外部分
|
||||
|
||||
你可以通过在站点中创建文件 `layouts/partials/custom/footer.html` 来在页脚中添加额外部分。
|
||||
|
||||
```html {filename="layouts/partials/custom/footer.html"}
|
||||
<!-- 你的页脚元素在这里 -->
|
||||
```
|
||||
|
||||
添加的部分将出现在页脚的版权部分之前。
|
||||
你可以使用 [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) 和 [Hugo 模板语法](https://gohugo.io/templates/) 来添加自己的内容。
|
||||
|
||||
页脚部分可用的 Hugo 变量有:`.switchesVisible` 和 `.copyrightVisible`。
|
||||
|
||||
## 自定义布局
|
||||
|
||||
可以在站点的 `layouts` 目录中创建同名文件来覆盖主题的默认布局。
|
||||
例如,要覆盖文档的 `single.html` 布局,在站点中创建文件 `layouts/docs/single.html`。
|
||||
可以通过在站点的 `layouts` 目录中创建同名文件来覆盖主题的布局。
|
||||
例如,要覆盖文档的 `single.html` 布局,可以在站点中创建文件 `layouts/docs/single.html`。
|
||||
|
||||
如需或许更多信息,转至 [Hugo Templates](https://gohugo.io/templates/)。
|
||||
更多信息,请参阅 [Hugo 模板文档][hugo-template-docs]。
|
||||
|
||||
## 进一步定制 Hextra
|
||||
## 进一步自定义
|
||||
|
||||
没有找到你想修改的内容?在 GitHub 上[创建 Discussion](https://github.com/imfing/hextra/discussions) 或为 Hextra 贡献你的智慧!
|
||||
没有找到你想要的?欢迎 [发起讨论](https://github.com/imfing/hextra/discussions) 或为主题做出贡献!
|
||||
|
||||
[hugo-template-docs]: https://gohugo.io/templates/
|
@ -1,16 +1,16 @@
|
||||
---
|
||||
title: "多语言"
|
||||
title: "多语言支持"
|
||||
weight: 1
|
||||
prev: /docs/advanced
|
||||
---
|
||||
|
||||
Hextra 支持使用 Hugo 的[多语言模式](https://gohugo.io/content-management/multilingual/) 创建多语言的网站。
|
||||
Hextra 支持使用 Hugo 的[多语言模式](https://gohugo.io/content-management/multilingual/)创建多语言网站。
|
||||
|
||||
<!--more-->
|
||||
|
||||
## 启用多语言支持
|
||||
## 启用多语言
|
||||
|
||||
为了使我们的网站支持多语言,我们需要告诉 Hugo 需要支持的语言。 在站点配置文件中添加:
|
||||
要使我们的网站支持多语言,我们需要告诉 Hugo 支持的语言。我们需要在站点配置文件中添加:
|
||||
|
||||
```yaml {filename="hugo.yaml"}
|
||||
defaultContentLanguage: en
|
||||
@ -26,9 +26,9 @@ languages:
|
||||
weight: 3
|
||||
```
|
||||
|
||||
## 按文件名管理翻译
|
||||
## 通过文件名管理翻译
|
||||
|
||||
Hugo 支持按文件名管理翻译。例如,如果我们有一个英文文件 `content/docs/_index.md`,我们可以创建一个翻译为法语的文件 `content/docs/_index.fr.md`。
|
||||
Hugo 支持通过文件名管理翻译。例如,如果我们有一个英文文件 `content/docs/_index.md`,我们可以创建一个文件 `content/docs/_index.fr.md` 作为法语翻译。
|
||||
|
||||
{{< filetree/container >}}
|
||||
{{< filetree/folder name="content" >}}
|
||||
@ -40,7 +40,7 @@ Hugo 支持按文件名管理翻译。例如,如果我们有一个英文文件
|
||||
{{< /filetree/folder >}}
|
||||
{{< /filetree/container >}}
|
||||
|
||||
注意:Hugo 还支持[按内容目录管理翻译](https://gohugo.io/content-management/multilingual/#translation-by-content-directory)。
|
||||
注意:Hugo 还支持[通过内容目录进行翻译](https://gohugo.io/content-management/multilingual/#translation-by-content-directory)。
|
||||
|
||||
## 翻译菜单项
|
||||
|
||||
@ -59,16 +59,25 @@ menu:
|
||||
weight: 2
|
||||
```
|
||||
|
||||
并在相应的 i18n 文件中进行翻译:
|
||||
|
||||
```yaml {filename="i18n/fr.yaml"}
|
||||
documentation: Documentation
|
||||
blog: Blog
|
||||
```
|
||||
|
||||
## 翻译字符串
|
||||
|
||||
要翻译其他地方的字符串,我们需要将翻译添加到相应的 `i18n` 文件中:
|
||||
要翻译其他地方的字符串,我们需要将翻译添加到相应的 i18n 文件中:
|
||||
|
||||
```yaml {filename="i18n/fr.yaml"}
|
||||
readMore: Lire la suite
|
||||
```
|
||||
|
||||
## 更多参考
|
||||
主题中使用的字符串列表可以在 `i18n/en.yaml` 文件中找到。
|
||||
|
||||
- [Hugo Multilingual Mode](https://gohugo.io/content-management/multilingual/)
|
||||
- [Hugo Multilingual Part 1: Content translation](https://www.regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/)
|
||||
- [Hugo Multilingual Part 2: Strings localization](https://www.regisphilibert.com/blog/2018/08/hugo-multilingual-part-2-i18n-string-localization/)
|
||||
## 了解更多
|
||||
|
||||
- [Hugo 多语言模式](https://gohugo.io/content-management/multilingual/)
|
||||
- [Hugo 多语言第一部分:内容翻译](https://www.regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/)
|
||||
- [Hugo 多语言第二部分:字符串本地化](https://www.regisphilibert.com/blog/2018/08/hugo-multilingual-part-2-i18n-string-localization/)
|
Reference in New Issue
Block a user