diff --git a/src/index.js b/src/index.js index a271e50..993af55 100644 --- a/src/index.js +++ b/src/index.js @@ -207,6 +207,9 @@ export async function render(resume) { return ``; }); + /** @type {Record} */ + resume.custom = {}; + if (Array.isArray(resume.basics?.profiles)) { const { profiles } = resume.basics; const xTwitter = profiles.find((profile) => { @@ -218,7 +221,7 @@ export async function render(resume) { let { username, url } = xTwitter; if (!username && url) { - const match = url.match(/https?:\/\/.+?\/(\w{1,15})/); + const match = url.match(/^https?:\/\/.+?\/(\w{1,15})/); if (match.length == 2) { username = match[1]; @@ -229,9 +232,15 @@ export async function render(resume) { username = `@${username}`; } - resume.custom = { - xTwitterHandle: username - } + resume.custom.xTwitterHandle = username; + } + } + + if (resume.basics?.image) { + const { image } = resume.basics; + + if (image.match(/^https?:\/\//)) { + resume.custom.ogImage = image; } } diff --git a/src/resume.handlebars b/src/resume.handlebars index 451b679..1383ff5 100644 --- a/src/resume.handlebars +++ b/src/resume.handlebars @@ -23,10 +23,13 @@ {{/if}} {{#if resume.basics.image}} - - + + {{/if}} + {{#if resume.custom.ogImage}} + {{#if resume.basics.name}} - + {{/if}} {{/if}} diff --git a/test/favicon.png b/test/favicon.png new file mode 100644 index 0000000..fa702ae Binary files /dev/null and b/test/favicon.png differ diff --git a/test/fixture.resume.json b/test/fixture.resume.json index 29d08b0..508f0bf 100644 --- a/test/fixture.resume.json +++ b/test/fixture.resume.json @@ -5,6 +5,7 @@ }, "basics": { "name": "Seth Falco", + "image": "./test/favicon.png", "label": "Open Sourcerer 🧙‍♂️", "email": "seth@example.org", "phone": "+00 0694201337",