From 508022df9655d56d1ad7eb9cc325181cfa7a716f Mon Sep 17 00:00:00 2001 From: XuluWarrior Date: Sun, 29 Sep 2024 21:20:27 +0100 Subject: [PATCH 1/2] Add location to contact details in sidebar --- index.js | 17 +++++++++++++++++ partials/basics.hbs | 1 + 2 files changed, 18 insertions(+) diff --git a/index.js b/index.js index 993fb48..cb7d6e0 100644 --- a/index.js +++ b/index.js @@ -70,6 +70,23 @@ Handlebars.registerHelper('skillLevel', function(str) { } }); +function formatLocation(locationDetails) { + const { postalCode, city, countryCode, region } = locationDetails; + const cityPlusCode = [city, postalCode].filter(value => !!value).join(" ") + return [cityPlusCode, region, countryCode ] + .filter(value => !!value) + .join(', ') +} + +Handlebars.registerHelper('formatLocation', function(locationDetails) { + return formatLocation(locationDetails); +}); + +Handlebars.registerHelper('locationUrl', function(locationDetails) { + const locationString = formatLocation(locationDetails); + return `https://www.google.com/maps/place/${locationString.replace(/ /g, "+")}`; +}); + // Resume.json used to have website property in some entries. This has been renamed to url. // However the demo data still uses the website property so we will also support the "wrong" property name. // Fix the resume object to use url property diff --git a/partials/basics.hbs b/partials/basics.hbs index f40e4c1..f261825 100644 --- a/partials/basics.hbs +++ b/partials/basics.hbs @@ -9,6 +9,7 @@