fix: allow all url protocols in social and menu links (#4)

Adding "| safeURL" allows the usage of "unsafe" url protocols such as irc:// or xmpp://
This commit is contained in:
Simon Wörner 2017-09-14 17:11:46 +02:00 committed by olOwOlo
parent d6ac9cd9ce
commit 8384f02483
4 changed files with 4 additions and 8 deletions

View file

@ -84,7 +84,7 @@ copyright = "" # default: author.name ↓ # 默认为下面配
alipay = "/path/to/your/alipay-qr-code.png" # 支付宝二维码 alipay = "/path/to/your/alipay-qr-code.png" # 支付宝二维码
[params.social] # 社交链接 [params.social] # 社交链接
a-email = "your@email.com" a-email = "mailto:your@email.com"
b-stack-overflow = "http://localhost:1313" b-stack-overflow = "http://localhost:1313"
c-twitter = "http://localhost:1313" c-twitter = "http://localhost:1313"
d-facebook = "http://localhost:1313" d-facebook = "http://localhost:1313"

View file

@ -2,11 +2,7 @@
{{- range $name, $path := .Site.Params.social }} {{- range $name, $path := .Site.Params.social }}
{{- if $path }} {{- if $path }}
{{- $realName := slicestr $name 2 }} {{- $realName := slicestr $name 2 }}
{{- if eq $realName "email" }} <a href="{{ $path | safeURL }}" class="iconfont icon-{{ $realName }}" title="{{ $realName }}"></a>
<a href="mailto:{{ $path }}" class="iconfont icon-{{ $realName }}" title="{{ $realName }}"></a>
{{- else }}
<a href="{{ $path }}" class="iconfont icon-{{ $realName }}" title="{{ $realName }}"></a>
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
<a href="{{ .Site.RSSLink }}" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a> <a href="{{ .Site.RSSLink }}" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>

View file

@ -6,7 +6,7 @@
<ul id="menu" class="menu"> <ul id="menu" class="menu">
{{ range .Site.Menus.main -}} {{ range .Site.Menus.main -}}
<li class="menu-item"> <li class="menu-item">
<a class="menu-item-link" href="{{ .URL }}">{{ .Name }}</a> <a class="menu-item-link" href="{{ .URL | safeURL }}">{{ .Name }}</a>
</li> </li>
{{- end }} {{- end }}
</ul> </ul>

View file

@ -11,7 +11,7 @@
<nav id="mobile-menu" class="mobile-menu slideout-menu"> <nav id="mobile-menu" class="mobile-menu slideout-menu">
<ul class="mobile-menu-list"> <ul class="mobile-menu-list">
{{ range .Site.Menus.main -}} {{ range .Site.Menus.main -}}
<a href="{{ .URL }}"> <a href="{{ .URL | safeURL }}">
<li class="mobile-menu-item">{{ .Name }}</li> <li class="mobile-menu-item">{{ .Name }}</li>
</a> </a>
{{- end }} {{- end }}