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
8 changes: 8 additions & 0 deletions src/_partials/date.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="date">
{{#if startDate}}
{{{date startDate}}}
{{#if (or endDate isEndDateRequired)}}
- {{{date endDate}}}
{{/if}}
{{/if}}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
</div>
34 changes: 34 additions & 0 deletions src/_partials/tenure.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="item">
{{#if name}}
<h3>
{{name}}
</h3>
{{/if}}

<div class="split">
{{#if position}}
<div class="work_position">
{{position}}
</div>
{{/if}}

{{> date isEndDateRequired=isEndDateRequired}}

{{#if url}}
<div class="work_website">
{{{link url}}}
</div>
{{/if}}
</div>

{{#if summary}}
<p>{{{markdown summary}}}</p>
{{/if}}
{{#if highlights.length}}
<ul>
{{#each highlights}}
<li>{{{markdown .}}}</li>
{{/each}}
</ul>
{{/if}}
</div>
18 changes: 18 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import Handlebars from 'handlebars';
import { minify } from 'html-minifier';
import { marked } from 'marked';
import { Messages } from './i18n/messages.js';

const PARTIALS_DIR = path.join(import.meta.dirname, '_partials');

/** @type {Intl.DateTimeFormatOptions} */
const LONG_DATE_FORMAT = { month: 'short', year: 'numeric' };
/** @type {Intl.DateTimeFormatOptions} */
Expand Down Expand Up @@ -65,6 +68,10 @@ Handlebars.registerHelper('link', /** @param {string} body */(body) => {
return `<a href="${body}">${host}</a>`;
});

Handlebars.registerHelper('or', (/** @type {unknown} */ a, /** @type {unknown} */ b) => {
return a || b;
});

/**
* Many users still have JSON Resumes written against old versions of the
* schema. We detect this and upgrade them to the latest version behind the
Expand Down Expand Up @@ -206,6 +213,17 @@ export async function render(resume) {
return `<time datetime="${datetime}">${localeString}</time>`;
});

for (const p of await fs.readdir(PARTIALS_DIR)) {
if (!p.endsWith('.handlebars')) {
continue;
}

Handlebars.registerPartial(
path.basename(p, '.handlebars'),
await fs.readFile(path.join(PARTIALS_DIR, p), 'utf-8')
);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

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

Expand Down
116 changes: 7 additions & 109 deletions src/resume.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -122,46 +122,7 @@
<section id="work">
<h2>{{i18n "work-experience"}}</h2>
{{#each resume.work}}
<div class="item">
{{#if name}}
<h3 class="work_name">
{{name}}
</h3>
{{/if}}

<div class="split">
{{#if position}}
<div class="work_position">
{{position}}
</div>
{{/if}}

<div class="work_date">
{{#if startDate}}
{{{date startDate}}} - {{{date endDate}}}
{{/if}}
</div>

{{#if url}}
<div class="work_website">
{{{link url}}}
</div>
{{/if}}
</div>

{{#if summary}}
<div class="summary">
<p>{{{markdown summary}}}</p>
</div>
{{/if}}
{{#if highlights.length}}
<ul class="highlights">
{{#each highlights}}
<li>{{{markdown .}}}</li>
{{/each}}
</ul>
{{/if}}
</div>
{{> tenure isEndDateRequired=true}}
{{/each}}
</section>
{{/if}}
Expand All @@ -170,51 +131,7 @@
<section id="volunteer">
<h2>{{i18n "volunteer"}}</h2>
{{#each resume.volunteer}}
<div class="item">
{{#if organization}}
<h3 class="company">
{{organization}}
</h3>
{{/if}}

<div class="split">
{{#if position}}
<div class="work_position">
{{position}}
</div>
{{/if}}

<div class="work_date">
{{#if startDate}}
<span class="startDate">
{{{date startDate}}}
</span>
<span class="endDate">
- {{{date endDate}}}
</span>
{{/if}}
</div>

{{#if url}}
<div class="work_website">
{{{link url}}}
</div>
{{/if}}
</div>

{{#if summary}}
<div class="summary">
<p>{{{markdown summary}}}</p>
</div>
{{/if}}
{{#if highlights.length}}
<ul class="highlights">
{{#each highlights}}
<li>{{{markdown .}}}</li>
{{/each}}
</ul>
{{/if}}
</div>
{{> tenure name=organization isEndDateRequired=true}}
{{/each}}
</section>
{{/if}}
Expand All @@ -241,15 +158,7 @@
{{entity}}
</div>
{{/if}}
<div class="project_date">
{{#if startDate}}
{{#if endDate}}
{{{date startDate}}} - {{{date endDate}}}
{{else}}
{{{date startDate}}}
{{/if}}
{{/if}}
</div>
{{> date isEndDateRequired=false}}
</div>

{{#if description}}
Expand Down Expand Up @@ -282,16 +191,7 @@
</div>
{{/if}}

<div class="study_date">
{{#if startDate}}
<span class="startDate">
{{{date startDate}}}
</span>
<span class="endDate">
- {{{date endDate}}}
</span>
{{/if}}
</div>
{{> date isEndDateRequired=true}}

{{#if url}}
<div class="work_website">
Expand Down Expand Up @@ -335,12 +235,10 @@
</div>
{{/if}}
{{#if level}}
<div class="level">
<em>{{level}}</em>
</div>
<em>{{level}}</em>
{{/if}}
{{#if keywords.length}}
<ul class="keywords">
<ul>
{{#each keywords}}
<li>{{.}}</li>
{{/each}}
Expand Down Expand Up @@ -397,7 +295,7 @@
{{#each resume.references}}
<div class="item">
{{#if reference}}
<blockquote class="reference">
<blockquote>
{{reference}}
</blockquote>
{{/if}}
Expand Down
13 changes: 3 additions & 10 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ header h2 {
margin-right: 2em;
}

.project_entity,
.project_date,
.project_website {
margin-bottom: 10px;
width: 30%;
}

.website,
.email,
.phone,
Expand All @@ -106,12 +99,12 @@ header h2 {
margin-top: .5em;
}

.work_date,
.date,
.work_position,
.work_website,
.institution,
.study_date,
.qualification {
.qualification,
.project_entity {
margin-bottom: 10px;
width: 30%;
}
Expand Down