Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add location to contact details in sidebar #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions example-resume.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"email": "[email protected]",
"phone": "0123 456 789",
"url": "http://portfoliosite.com",
"location": {
"city": "San Francisco",
"countryCode": "US"
},
"summary": "Summarise your career here lorem ipsum dolor sit amet, consectetuer adipiscing elit. You can [download this free resume/CV template here](https://github.com/XuluWarrior/jsonresume-theme-orbit-original). Aenean commodo ligula eget dolor aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu.",
"profiles": [
{
Expand Down
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions partials/basics.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ul class="list-unstyled contact-list">
{{#if email}}<li class="email"><i class="fa fa-envelope"></i><a href="mailto:{{email}}">{{email}}</a></li>{{/if}}
{{#if phone}}<li class="phone"><i class="fa fa-phone"></i><a href="tel:{{phone}}">{{phone}}</a></li>{{/if}}
{{#if location}}<li class="location"><i class="fa fa-map-marker"></i><a href="{{locationUrl location}}" target="_blank">{{formatLocation location}}</a></li>{{/if}}
{{#if url}}<li class="website"><i class="fa fa-globe"></i><a href="{{url}}" target="_blank">{{displayUrl url}}</a></li>{{/if}}

{{#each profiles}}
Expand Down