mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-27 04:03:48 +01:00
feat(helper): add helper/icon
This commit is contained in:
parent
4e646fe15e
commit
871e8c0bd5
6 changed files with 12 additions and 6 deletions
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
6
layouts/partials/helper/icon.html
Normal file
6
layouts/partials/helper/icon.html
Normal 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 -}}
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in a new issue