【发布时间】:2018-03-28 01:00:08
【问题描述】:
这个 sn-p 在 Hugo 上效果很好:
{{ if and (or .IsPage .IsSection) .Site.Params.contentCommitsURL }}
{{ $File := .File }}
{{ $Site := .Site }}
{{with $File.Path }}
<a href="{{ $Site.Params.contentCommitsURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }}" target="blank">Link to API call</a>
{{ end }}
{{ end }}
与,
[Params] contentCommitsURL = https://api.github.com/repos/csitauthority/CSITauthority.github.io/commits?path=HUGO/content/它能够漂亮地生成以下链接
在
layouthtml 文件中。
问题描述
URL 已生成。现在我正在努力弄清楚如何将命令{ $Site.Params.contentCommitsURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }} 连接到页面变量中,例如{{ $url }}
例如:
{{ $url := {{ $Site.Params.contentCommitsURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }} }}
没用
但以下是:
{{ $url := "https://api.github.com/repos/csitauthority/CSITauthority.github.io/commits?path=HUGO/content/post/vlan-101.md"}}
我希望能够做这样的事情:
{{ $url := $Site.Params.contentCommitsURL + (replace $File.Dir "\\" "/") + $File.LogicalName }}
^显然,这是行不通的。我想知道有什么作用。
【问题讨论】:
标签: hugo