hugo-theme-moments/layouts/partials/link-block.html
2021-08-06 18:29:10 +08:00

33 lines
No EOL
980 B
HTML

{{ $logo_file := "default_link_logo.png" }}
{{ if eq 1 (len (findRE `(https?://)?mp\.weixin\.qq\.com([-a-zA-Z0-9()@:%\+.~#?&/=_]*)` .a)) }}
{{ $logo_file = "wechat.png"}}
{{ end }}
{{ if eq 1 (len (findRE `(https?://)?(www\.)?bilibili\.com/video/([-a-zA-Z0-9()@:%\+.~#?&/=_]*)` .a)) }}
{{ $logo_file = "bilibili.png"}}
{{ end }}
{{ if eq 1 (len (findRE `(https?://)?(www\.)?github\.com([-a-zA-Z0-9()@:%\+.~#?&/=_]*)` .a)) }}
{{ $logo_file = "github.png"}}
{{ end }}
<!-- todo add zhihu -->
<div class="share-link-block">
<table class="link-table">
<tr>
<td>
{{ $baseurl := .baseurl}}
{{ with .logo }}
<img src="{{ . }}" class="link-logo">
{{ else }}
<img src="{{ $baseurl }}/link-logos/{{ $logo_file }}" class="link-logo">
{{ end }}
</td>
<td style="padding-left: 20px">
<a href="{{ .a }}">{{.word}}</a>
</td>
</tr>
</table>
</div>