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:
parent
2d94f7449a
commit
69acce5ec7
4 changed files with 20 additions and 10 deletions
|
|
@ -61,6 +61,14 @@ title = "Jane Doe - Nutrition Coach & Chef Consultant"
|
|||
[params.meta]
|
||||
keywords = "some, keywords, for, seo, you, know, google, duckduckgo, and, such"
|
||||
|
||||
[params.contact]
|
||||
email = "mail@janedoe.com"
|
||||
phone = "+49 1111 555555"
|
||||
[[params.contacts]]
|
||||
label = "phone"
|
||||
value = "+49 1111 555555"
|
||||
url = "tel: +49 1111 555555"
|
||||
icon = "fa fa-phone"
|
||||
|
||||
[[params.contacts]]
|
||||
label = "email"
|
||||
value = "mail@janedoe.com"
|
||||
url = "mailto: mail@janedoe.com"
|
||||
icon = "fa fa-envelope"
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ weight: 4
|
|||
header_menu: true
|
||||
---
|
||||
|
||||
{{<icon class="fa fa-envelope">}} [{{<email>}}](mailto:{{<email>}})
|
||||
|
||||
{{<icon class="fa fa-phone">}} [{{<phone>}}](tel:{{<phone>}})
|
||||
{{<contact_list>}}
|
||||
|
||||
Let us get in touch!
|
||||
|
|
|
|||
|
|
@ -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 }}
|
||||
|
|
|
|||
3
layouts/shortcodes/contact_list.html
Normal file
3
layouts/shortcodes/contact_list.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{{ range .Site.Params.contacts }}
|
||||
<p><i class="{{ .icon}}"></i> <a href="{{ .url }}">{{ .value }}</a></p>
|
||||
{{ end }}
|
||||
Loading…
Add table
Reference in a new issue