Handle website contacts dynamically

This commits change the way contacts params are handled: instead of
declaring them statically, they are declared as an array of tables in
the TOML configuration file, then they are displayed in the two sections
(homepage and footer) of the website through the {{ range }} statement.

This makes handling multiple contacts params easier and avoids the
need of changing manually this two files:
- `layouts/partials/footer.html`;
- `exampleSite/content/homepage/contact.md`;

Signed-off-by: Filippo Fontana <filippofontana1998@gmail.com>
This commit is contained in:
Filippo Fontana 2024-03-09 16:33:59 +01:00 committed by zjedi
parent 2d94f7449a
commit 69acce5ec7
4 changed files with 20 additions and 10 deletions

View file

@ -18,14 +18,15 @@
{{ end }}
{{ if ne .Site.Params.footer.showContactIcons false }}
{{ with .Site.Params.contact }}
<section class="icons">
<ol>
<li><a href="mailto:{{ .email }}" aria-label='{{ i18n "email" }}'><i class="fa fa-envelope"></i></a></li>
<li><a href="tel:{{ .phone }}" aria-label='{{ i18n "phone" }}'><i class="fa fa-phone"></i></a></li>
{{ range .Site.Params.contacts }}
<li>
<a href="{{ .url }}" aria-label='{{ i18n "{{ .label }}" }}'><i class="{{ .icon }}"></i></a>
</li>
{{ end }}
</ol>
</section>
{{ end }}
{{ end }}
{{ with .Site.Params.copyright }}

View file

@ -0,0 +1,3 @@
{{ range .Site.Params.contacts }}
<p><i class="{{ .icon}}"></i>&nbsp;<a href="{{ .url }}">{{ .value }}</a></p>
{{ end }}