2023-01-30 02:38:45 +01:00
|
|
|
import html from '../utils/html.js'
|
|
|
|
import markdown from '../utils/markdown.js'
|
|
|
|
import Duration from './duration.js'
|
|
|
|
import Link from './link.js'
|
|
|
|
|
2023-09-28 02:50:43 +02:00
|
|
|
/** @typedef {NonNullable<import('../schema.d.ts').ResumeSchema['work']>[number]} Work */
|
|
|
|
/** @typedef {Pick<Work, 'highlights' | 'location' | 'position' | 'startDate' | 'endDate' | 'summary'>} NestedWorkItem */
|
|
|
|
/** @typedef {Pick<Work, 'description' | 'name' | 'url'> & { items: NestedWorkItem[] }} NestedWork */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import('../schema.d.ts').ResumeSchema['work']} work
|
|
|
|
* @returns {string | false}
|
|
|
|
*/
|
2023-01-30 02:38:45 +01:00
|
|
|
export default function Work(work = []) {
|
2023-08-29 02:36:34 +02:00
|
|
|
const nestedWork = work.reduce((acc, { description, name, url, ...rest }) => {
|
|
|
|
const prev = acc[acc.length - 1]
|
|
|
|
if (prev && prev.name === name && prev.description === description && prev.url === url) prev.items.push(rest)
|
|
|
|
else acc.push({ description, name, url, items: [rest] })
|
|
|
|
return acc
|
2023-09-28 02:50:43 +02:00
|
|
|
}, /** @type {NestedWork[]} */ ([]))
|
2023-08-29 02:36:34 +02:00
|
|
|
|
2023-01-30 02:38:45 +01:00
|
|
|
return work.length > 0 && html`
|
|
|
|
<section id="work">
|
|
|
|
<h3>Work</h3>
|
|
|
|
<div class="stack">
|
2023-08-29 02:36:34 +02:00
|
|
|
${nestedWork.map(({ description, name, url, items = [] }) => html`
|
2023-01-30 02:38:45 +01:00
|
|
|
<article>
|
|
|
|
<header>
|
2023-08-08 00:32:37 +02:00
|
|
|
<h4>${Link(url, name)}</h4>
|
2023-01-30 02:38:45 +01:00
|
|
|
<div class="meta">
|
2023-08-29 02:36:34 +02:00
|
|
|
${description && html`<div>${description}</div>`}
|
2023-01-30 02:38:45 +01:00
|
|
|
</div>
|
|
|
|
</header>
|
2023-08-29 02:36:34 +02:00
|
|
|
<div class="timeline">
|
|
|
|
${items.map(({highlights = [], location, position, startDate, endDate, summary }) => html`
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<h5>${position}</h5>
|
|
|
|
<div class="meta">
|
2023-09-28 02:50:43 +02:00
|
|
|
${startDate && html`<div>${Duration(startDate, endDate)}</div>`}
|
2023-08-29 02:36:34 +02:00
|
|
|
${location && html`<div>${location}</div>`}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
${summary && markdown(summary)}
|
|
|
|
${highlights.length > 0 && html`
|
|
|
|
<ul>
|
|
|
|
${highlights.map(highlight => html`<li>${markdown(highlight)}</li>`)}
|
|
|
|
</ul>
|
|
|
|
`}
|
|
|
|
</div>
|
|
|
|
`)}
|
|
|
|
</div>
|
2023-01-30 02:38:45 +01:00
|
|
|
</article>
|
|
|
|
`)}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
`
|
|
|
|
}
|