Pre
Syntax
MENUENTRY.Pre
Returns
template.HTML
在这个站点配置中,我们启用了 表情符号短代码 的渲染,并在每个菜单条目的前(pre)后(post)添加了表情符号短代码:
hugo.
enableEmoji: true
menu:
main:
- name: 关于
pageRef: /about
post: ':point_left:'
pre: ':point_right:'
weight: 10
- name: 联系我们
pageRef: /contact
post: ':arrow_left:'
pre: ':arrow_right:'
weight: 20
enableEmoji = true
[menu]
[[menu.main]]
name = '关于'
pageRef = '/about'
post = ':point_left:'
pre = ':point_right:'
weight = 10
[[menu.main]]
name = '联系我们'
pageRef = '/contact'
post = ':arrow_left:'
pre = ':arrow_right:'
weight = 20
{
"enableEmoji": true,
"menu": {
"main": [
{
"name": "关于",
"pageRef": "/about",
"post": ":point_left:",
"pre": ":point_right:",
"weight": 10
},
{
"name": "联系我们",
"pageRef": "/contact",
"post": ":arrow_left:",
"pre": ":arrow_right:",
"weight": 20
}
]
}
}
渲染菜单的代码如下:
<ul>
{{ range .Site.Menus.main }}
<li>
{{ .Pre | markdownify }}
<a href="{{ .URL }}">{{ .Name }}</a>
{{ .Post | markdownify }}
</li>
{{ end }}
</ul>