sync contribute/style/hugo-shortcodes/index.md

Signed-off-by: bzsuni <bingzhe.sun@daocloud.io>
pull/42420/head
bzsuni 2023-08-07 15:52:12 +08:00
parent 8b07bec2e3
commit 679d971f42
No known key found for this signature in database
GPG Key ID: 0930F8BCF54E160B
1 changed files with 17 additions and 9 deletions

View File

@ -449,13 +449,14 @@ Renders to:
{{< /tabs >}}
<!--
### Source code files
You can use the `{{</* codenew */>}}` shortcode to embed the contents of file
## Source code files
You can use the `{{</* code */>}}` shortcode to embed the contents of file
in a code block to allow users to download or copy its content to their clipboard.
This shortcode is used when the contents of the sample file is generic and reusable,
and you want the users to try it out themselves.
-->
你可以使用 `{{</* codenew */>}}` 短代码将文件内容嵌入代码块中,
## 源代码文件
你可以使用 `{{</* code */>}}` 短代码将文件内容嵌入代码块中,
以允许用户下载或复制其内容到他们的剪贴板。
当示例文件的内容是通用的、可复用的,并且希望用户自己尝试使用示例文件时,
可以使用此短代码。
@ -475,7 +476,7 @@ For example:
如果未提供 `language` 参数,短代码将尝试根据文件扩展名推测编程语言。
```none
{{</* codenew language="yaml" file="application/deployment-scale.yaml" */>}}
{{</* code language="yaml" file="application/deployment-scale.yaml" */>}}
```
<!--
@ -483,28 +484,35 @@ The output is:
-->
输出是:
{{< codenew language="yaml" file="application/deployment-scale.yaml" >}}
{{< code language="yaml" file="application/deployment-scale.yaml" >}}
<!--
When adding a new sample file, such as a YAML file, create the file in one
of the `<LANG>/examples/` subdirectories where `<LANG>` is the language for
the page. In the markdown of your page, use the `codenew` shortcode:
the page. In the markdown of your page, use the `code` shortcode:
-->
添加新的示例文件(例如 YAML 文件)时,在 `<LANG>/examples/`
子目录之一中创建该文件,其中 `<LANG>` 是页面的语言。
在你的页面的 markdown 文本中,使用 `codenew` 短代码:
在你的页面的 markdown 文本中,使用 `code` 短代码:
```none
{{</* codenew file="<RELATIVE-PATH>/example-yaml>" */>}}
{{</* code file="<RELATIVE-PATH>/example-yaml>" */>}}
```
其中 `<RELATIVE-PATH>` 是要包含的示例文件的路径,相对于 `examples` 目录。
以下短代码引用位于 `/content/en/examples/configmap/configmaps.yaml` 的 YAML 文件。
```none
{{</* codenew file="configmap/configmaps.yaml" */>}}
{{</* code file="configmap/configmaps.yaml" */>}}
```
<!--
The legacy `{{%/* codenew */%}}` shortcode is being replaced by `{{%/* code */%}}`.
Use `{{%/* code */%}}` in new documentation.
-->
传统的 `{{%/* codenew */%}}` 短代码将被替换为 `{{%/* code */%}}`
在新文档中使用 `{{%/* code */%}}`
<!--
## Third party content marker
-->