change the way svg icon is get

use data instead of if else in partial, this makes iterating and display all the icons possible
This commit is contained in:
Reorx 2022-04-13 21:09:58 +08:00
parent 8fb2f38f43
commit 8a0915bb81
4 changed files with 156 additions and 82 deletions

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
<p>{{ .Content | markdownify }}</p>
</section>
<footer class="entry-footer">
{{ partial "social_icons.html" site.Params.socialIcons }}
{{ partial "social_icons.html" (dict "icons" site.Params.socialIcons "svg" $.Site.Data.svg) }}
</footer>
</article>
{{- end -}}

View File

@ -29,7 +29,7 @@
{{- end }}
<h1>{{ .title | default site.Title | markdownify }}</h1>
<span>{{ .subtitle | markdownify }}</span>
{{- partial "social_icons.html" site.Params.socialIcons -}}
{{- partial "social_icons.html" (dict "icons" site.Params.socialIcons "svg" $.Site.Data.svg) -}}
{{- with .buttons }}
<div class="buttons">
@ -42,4 +42,4 @@
{{- end }}
</div>
{{- end}}
</div>
</div>

View File

@ -1,7 +1,8 @@
<div class="social-icons">
{{- range . }}
{{- range .icons }}
<a href="{{ trim .url " " }}" target="_blank" rel="noopener noreferrer me" title="{{ .name | title }}">
{{ partial "svg.html" . }}
{{- $icon_name := ( trim .name " " | lower )}}
{{ safeHTML (index $.svg $icon_name | default $.svg.default) }}
</a>
{{- end }}
</div>