这是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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License (MIT)

Copyright (c) 2014-2014 James Spencer
Copyright (c) 2022-2022 JSON Resume and Contributors
Copyright (c) 2022-2023 JSON Resume and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 27 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,33 @@ function render(resume) {
const template = fs.readFileSync(__dirname + "/resume.handlebars", "utf-8");

const markedResume = traverseString(resume, markdownProperties, parseMarkdown);
const { profiles } = markedResume.basics;

if (Array.isArray(profiles)) {
const twitter = profiles.find((profile) => {
return profile.network.toLowerCase().includes('twitter');
});

if (twitter) {
let { username, url } = twitter;

if (!username && url) {
const match = url.match(/https?:\/\/.+?\/([\w]{1,15})/);

if (match.length == 2) {
username = match[1];
}
}

if (username && !username.startsWith('@')) {
username = `@${username}`;
}

markedResume.custom = {
twitterHandle: username
}
}
}

return Handlebars.compile(template)({
css: css,
Expand Down
21 changes: 18 additions & 3 deletions resume.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimal-ui">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary">

{{#resume.basics}}
<title>{{name}} - CV</title>
Expand All @@ -11,11 +13,20 @@
<meta property="og:site_name" content="{{name}}">
<meta property="og:title" content="{{label}}">
<meta property="og:description" content="{{summary}}">
<meta property="og:type" content="website">

<meta name="twitter:card" content="summary">
{{#if image}}
<link rel="icon" href="{{image}}">
<meta property="og:image" content="{{image}}">
<meta property="og:image:alt" content="Avatar of {{name}}.">
{{/if}}
{{/resume.basics}}

{{#resume.custom}}
{{#if twitterHandle}}
<meta name="twitter:site" content="{{twitterHandle}}">
{{/if}}
{{/resume.custom}}

<style>
{{{css}}}
</style>
Expand Down Expand Up @@ -371,5 +382,9 @@
{{/if}}

</div>

<script>
console.log('Theme made with 💕 using JSON Resume and Handlebars!\nhttps://github.com/jsonresume/jsonresume-theme-class')
</script>
</body>
</html>