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-10-08 01:23:03 +02:00
|
|
|
return (
|
|
|
|
work.length > 0 &&
|
|
|
|
html`
|
|
|
|
<section id="work">
|
|
|
|
<h3>Work</h3>
|
|
|
|
<div class="stack">
|
|
|
|
${nestedWork.map(
|
|
|
|
({ description, name, url, items = [] }) => html`
|
|
|
|
<article>
|
|
|
|
<header>
|
|
|
|
<h4>${Link(url, name)}</h4>
|
|
|
|
<div class="meta">${description && html`<div>${description}</div>`}</div>
|
|
|
|
</header>
|
|
|
|
<div class="timeline">
|
|
|
|
${items.map(
|
|
|
|
({ highlights = [], location, position, startDate, endDate, summary }) => html`
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<h5>${position}</h5>
|
|
|
|
<div class="meta">
|
|
|
|
${startDate && html`<div>${Duration(startDate, endDate)}</div>`}
|
|
|
|
${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>
|
|
|
|
`,
|
|
|
|
)}
|
2023-08-29 02:36:34 +02:00
|
|
|
</div>
|
2023-10-08 01:23:03 +02:00
|
|
|
</article>
|
|
|
|
`,
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
`
|
|
|
|
)
|
2023-01-30 02:38:45 +01:00
|
|
|
}
|