feat(helper): add helper/icon

This commit is contained in:
Jimmy Cai 2020-10-10 00:27:56 +02:00
parent 4e646fe15e
commit 871e8c0bd5
No known key found for this signature in database
GPG key ID: 3EA408E527F37B18
6 changed files with 12 additions and 6 deletions

View file

@ -30,7 +30,7 @@
{{- if not .Date.IsZero -}}
<footer class="article-time">
{{ (resources.Get "icons/clock.svg").Content | safeHTML }}
{{ partial "helper/icon" "clock" }}
<time class="article-time--published">
{{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}
</time>

View file

@ -3,14 +3,14 @@
{{ if and (.Site.Params.article.license.enabled) (not (eq .Params.license false)) }}
<section class="article-copyright">
{{ (resources.Get "icons/copyright.svg").Content | safeHTML }}
{{ partial "helper/icon" "copyright" }}
<span>{{ default .Site.Params.article.license.default .Params.license }}</span>
</section>
{{ end }}
{{- if ne .Lastmod .Date -}}
<section class="article-time">
{{ (resources.Get "icons/clock.svg").Content | safeHTML }}
{{ partial "helper/icon" "clock" }}
<span class="article-time--modified">
{{ T "lastUpdatedOn" }} {{ .Lastmod.Format ( or .Site.Params.dateFormat.lastUpdated "Jan 02, 2006 15:04 MST" ) }}
</span>

View file

@ -0,0 +1,6 @@
{{- $iconFile := resources.GetMatch (printf "icons/%s.svg" .) -}}
{{- if $iconFile -}}
{{- $iconFile.Content | safeHTML -}}
{{- else -}}
{{- errorf "Error: icon '%s.svg' is not found under 'assets/icons' folder" . -}}
{{- end -}}

View file

@ -33,7 +33,7 @@
<li {{ if $active }} class='current' {{ end }}>
<a href='{{ .URL | absLangURL }}'>
{{ if .Pre }}
{{ (resources.Get (delimit (slice "icons/" .Pre ".svg") "")).Content | safeHTML }}
{{ partial "helper/icon" .Pre }}
{{ end }}
<span>{{- .Name -}}</span>
</a>

View file

@ -1,6 +1,6 @@
<section class="widget archives">
<div class="widget-icon">
{{ (resources.Get "icons/infinity.svg").Content | safeHTML }}
{{ partial "helper/icon" "infinity" }}
</div>
<h1 class="widget-title">{{ T "widgetArchivesTitle" }}</h1>

View file

@ -1,6 +1,6 @@
<section class="widget tagCloud">
<div class="widget-icon">
{{ (resources.Get "icons/tag.svg").Content | safeHTML }}
{{ partial "helper/icon" "tag" }}
</div>
<h1 class="widget-title">{{ T "widgetTagCloudTitle" }}</h1>