From 4b5df3d46c4fba20184f3bafd7515cd561ab6d65 Mon Sep 17 00:00:00 2001 From: Jarno Rankinen Date: Sun, 3 Dec 2023 22:59:37 +0200 Subject: [PATCH] Header and footer populated from yaml --- data/resume.yaml | 12 ++++++++++-- main.go | 2 ++ resume.go | 20 ++++++++++++++++---- templates/index.html | 23 ++++++++++++++--------- templates/metatag.html | 12 ++++++------ templates/socialIcons.html | 36 ++++++++++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 templates/socialIcons.html diff --git a/data/resume.yaml b/data/resume.yaml index d1d47da..6c89897 100644 --- a/data/resume.yaml +++ b/data/resume.yaml @@ -9,5 +9,13 @@ meta: theme-color: "#bd93f9" title: "Go-Resume - dynamic resume" description: "Software Developer" -theme: "light" - + favicon: "" +theme: "dark" +profile: + name: "Job Applicant" + title: "Software Developer" + city: "Oulu, Finland" + phone: "+358 xx xxx xxxx" + email: "iwannajob@email.com" + photo: "path-or-url-to-avatar" + socials: [] \ No newline at end of file diff --git a/main.go b/main.go index ca3d47e..8ebcbcd 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "net/http" "slices" "strings" + "time" ) //go:embed "static/css/*.css" "templates/*.html" @@ -52,6 +53,7 @@ func home(w http.ResponseWriter, r *http.Request) { urlSlice := strings.Split(r.URL.Path, "/") data.Theme = urlSlice[len(urlSlice)-1] } + data.Year = time.Now().Format("2006") err = tmpl.Execute(w, *data) if err != nil { slog.Error(err.Error()) diff --git a/resume.go b/resume.go index 259e73b..d2ea680 100644 --- a/resume.go +++ b/resume.go @@ -1,8 +1,20 @@ package main type Resume struct { - Theme string `yaml:"theme"` - Meta *Meta `yaml:"meta"` + Theme string `yaml:"theme"` + Meta *Meta `yaml:"meta"` + Profile *Profile `yaml:"profile"` + Year string +} + +type Profile struct { + Name string `yaml:"name"` + Title string `yaml:"title"` + City string `yaml:"city"` + Phone string `yaml:"phone"` + Email string `yaml:"email"` + Socials Socials `yaml:"socials"` + Photo string `yaml:"photo"` } type job struct { @@ -32,13 +44,13 @@ type skill struct { type skills []skill -type social struct { +type Social struct { Media string `yaml:"media"` UserId string `yaml:"userId"` Link string `yaml:"link"` } -type socials []social +type Socials []Social type Meta struct { Language string `yaml:"language"` diff --git a/templates/index.html b/templates/index.html index c74beac..8d7fe43 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,7 +2,7 @@ - {{ template "meta" .Meta }} + {{ template "meta" . }} @@ -16,26 +16,30 @@
-

<%= content.data.profile.name %>

-

<%= content.data.profile.title %>

+

{{ .Profile.Name }}

+

{{ .Profile.Title }}

- Profile photo + Profile photo

- <%= content.data.profile.city %> + {{ .Profile.City }}

- <%= content.data.profile.phone %> + {{ .Profile.Phone }}

- <%= content.data.profile.mail %> + {{ .Profile.Email }}

+ {{ with .Profile.Socials }} + {{ range .Profile.Socials }} <% include /socialIcons %> + {{ end }} + {{ end }}
@@ -152,8 +156,9 @@ See Light Theme {{ end }}
- Copyright © 2018-2019 by - Irfan Maulana + Copyright © {{ .Year }} {{ .Profile.Name }}. All rights Reserved. +
+ Powered by go-resume diff --git a/templates/metatag.html b/templates/metatag.html index 8e8a918..d0802cc 100644 --- a/templates/metatag.html +++ b/templates/metatag.html @@ -3,14 +3,14 @@ - - - - - + + + + + -AUTHOR FROM YAML +{{ .Profile.Name }} - {{ .Profile.Title }} diff --git a/templates/socialIcons.html b/templates/socialIcons.html new file mode 100644 index 0000000..e64a583 --- /dev/null +++ b/templates/socialIcons.html @@ -0,0 +1,36 @@ +{{ define "socialIcons" }} +
+ +
+ +
+ +
+ +
+ <%= content.data.social.linkedin.name %> + + + +
+ +
+ <%= content.data.social.github.name %> + + + +
+{{ end }} \ No newline at end of file