这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
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
17 changes: 13 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ export async function render(resume) {
return `<time datetime="${datetime}">${localeString}</time>`;
});

/** @type {Record<string, unknown>} */
resume.custom = {};

if (Array.isArray(resume.basics?.profiles)) {
const { profiles } = resume.basics;
const xTwitter = profiles.find((profile) => {
Expand All @@ -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];
Expand All @@ -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;
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/resume.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
{{/if}}

{{#if resume.basics.image}}
<meta property="og:image" content="{{resume.basics.image}}">
<link rel="icon" href="{{resume.basics.image}}">
<link href="{{resume.basics.image}}" rel="icon">
{{/if}}
{{#if resume.custom.ogImage}}
<meta property="og:image" content="{{resume.custom.ogImage}}">
{{#if resume.basics.name}}
<meta property="og:image:alt" content="{{i18n "avatar-description" "name" resume.basics.name}}">
<meta property="og:image:alt" content="{{i18n " avatar-description" "name"
resume.basics.name}}">
{{/if}}
{{/if}}

Expand Down
Binary file added test/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/fixture.resume.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
},
"basics": {
"name": "Seth Falco",
"image": "./test/favicon.png",
"label": "Open Sourcerer 🧙‍♂️",
"email": "seth@example.org",
"phone": "+00 0694201337",
Expand Down