From 69acce5ec7f56092554474824a11cf6204811fa1 Mon Sep 17 00:00:00 2001 From: Filippo Fontana Date: Sat, 9 Mar 2024 16:33:59 +0100 Subject: [PATCH] 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 --- exampleSite/config.toml | 14 +++++++++++--- exampleSite/content/homepage/contact.md | 4 +--- layouts/partials/footer.html | 9 +++++---- layouts/shortcodes/contact_list.html | 3 +++ 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 layouts/shortcodes/contact_list.html diff --git a/exampleSite/config.toml b/exampleSite/config.toml index ab20345..165978b 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -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" diff --git a/exampleSite/content/homepage/contact.md b/exampleSite/content/homepage/contact.md index 6615de8..0d01e14 100644 --- a/exampleSite/content/homepage/contact.md +++ b/exampleSite/content/homepage/contact.md @@ -4,8 +4,6 @@ weight: 4 header_menu: true --- -{{}} [{{}}](mailto:{{}}) - -{{}} [{{}}](tel:{{}}) +{{}} Let us get in touch! diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 3db45b3..30ce91c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -18,14 +18,15 @@ {{ end }} {{ if ne .Site.Params.footer.showContactIcons false }} - {{ with .Site.Params.contact }}
    -
  1. -
  2. + {{ range .Site.Params.contacts }} +
  3. + +
  4. + {{ end }}
- {{ end }} {{ end }} {{ with .Site.Params.copyright }} diff --git a/layouts/shortcodes/contact_list.html b/layouts/shortcodes/contact_list.html new file mode 100644 index 0000000..483a766 --- /dev/null +++ b/layouts/shortcodes/contact_list.html @@ -0,0 +1,3 @@ +{{ range .Site.Params.contacts }} +

 {{ .value }}

+{{ end }}