From 76fbe5c70449021ac26b3b3b6be932a2e1e95895 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Thu, 23 Feb 2023 20:36:51 +0000 Subject: [PATCH] fix: more flexibility in Links and Contact section Add more flexibility for the Links and Contact sections by removing the strict types and replacing them with map[string]string. --- cv.go | 25 ++++++++++--------------- example/cv.json | 9 +++++---- main.go | 6 ------ templates/tex/cv.tmpl.tex | 11 ++++++----- 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/cv.go b/cv.go index d8b5da0..a3c117a 100644 --- a/cv.go +++ b/cv.go @@ -1,16 +1,16 @@ package main type Cv struct { - FirstName string `json:"firstName"` - LastName string `json:"lastName"` - JobTitle string `json:"jobTitle"` - Contact Contact `json:"contact"` - Links Links `json:"links"` - Summary []string `json:"summary"` - Skills []Skills `json:"skills"` - Employment []Experience `json:"employment"` - Education []Experience `json:"education"` - Interests []string `json:"interests"` + FirstName string `json:"firstName"` + LastName string `json:"lastName"` + JobTitle string `json:"jobTitle"` + Contact map[string]string `json:"contact"` + Links map[string]string `json:"links"` + Summary []string `json:"summary"` + Skills []Skills `json:"skills"` + Employment []Experience `json:"employment"` + Education []Experience `json:"education"` + Interests []string `json:"interests"` } type Contact struct { @@ -19,11 +19,6 @@ type Contact struct { Location string `json:"location"` } -type Links struct { - LinkedIn string `json:"linkedin"` - GitHub string `json:"github"` -} - type Skills struct { Category string `json:"category"` Values []string `json:"values"` diff --git a/example/cv.json b/example/cv.json index 61f3b0d..797a222 100644 --- a/example/cv.json +++ b/example/cv.json @@ -3,12 +3,13 @@ "lastName": "Smith", "jobTitle": "Software Engineer", "contact": { - "email": "john.smith@example.io", - "location": "England, UK" + "Email": "john.smith@example.io", + "Phone": "07123 456 789", + "Location": "England, UK" }, "links": { - "linkedin": "https://www.linkedin.com/in/john-smith-2YASMKJMP", - "github": "https://github.com/johnsmaith-example-gh" + "LinkedIn": "https://www.linkedin.com/in/john-smith-2YASMKJMP", + "GitHub": "https://github.com/johnsmith-example-gh" }, "summary": [ "Rem quia eveniet sit, quis asperiores ea sed repellat non molestias aut accusamus aliquid et dolorem.", diff --git a/main.go b/main.go index eb6c72d..f3238c4 100644 --- a/main.go +++ b/main.go @@ -57,12 +57,6 @@ func tex(input, tempDir string) (string, error) { return "", fmt.Errorf("unable to decode JSON data; %w", err) } - // if CV_CONTACT_PHONE is set then add it to the CV - phone := os.Getenv("CV_CONTACT_PHONE") - if len(phone) > 0 { - cv.Contact.Phone = phone - } - output := filepath.Join(tempDir, "cv.tex") file, err := os.Create(output) diff --git a/templates/tex/cv.tmpl.tex b/templates/tex/cv.tmpl.tex index c941374..24f2163 100644 --- a/templates/tex/cv.tmpl.tex +++ b/templates/tex/cv.tmpl.tex @@ -5,12 +5,13 @@ \starttitleAndContact \cvtitle{<<.FirstName>> <<.LastName>>}{<<.JobTitle>>} \titleAndContact - {\bf Email:} <<.Contact.Email>>\blank[none] - <>{\bf Phone:} <<.Contact.Phone>>\blank[none]<> - {\bf Location:} <<.Contact.Location>>\blank[medium] + <> + {\bf <<$k>>:} <<$v>>\blank[none] + <>\blank[medium] - <>{\bf LinkedIn:} <<.Links.LinkedIn>>\blank[none]<> - <>{\bf GitHub:} <<.Links.GitHub>>\blank[none]<> + <> + {\bf <<$k>>:} <<$v>>\blank[none] + <> \stoptitleAndContact \section{SUMMARY}