import html from '../utils/html.js' import markdown from '../utils/markdown.js' import Duration from './duration.js' import Link from './link.js' /** @typedef {NonNullable[number]} Work */ /** @typedef {Pick} NestedWorkItem */ /** @typedef {Pick & { items: NestedWorkItem[] }} NestedWork */ /** * @param {import('../schema.d.ts').ResumeSchema['work']} work * @returns {string | false} */ export default function Work(work = []) { 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 }, /** @type {NestedWork[]} */ ([])) return ( work.length > 0 && html`

Work

${nestedWork.map( ({ description, name, url, items = [] }) => html`

${Link(url, name)}

${description && html`
${description}
`}
${items.map( ({ highlights = [], location, position, startDate, endDate, summary }) => html`
${position}
${startDate && html`
${Duration(startDate, endDate)}
`} ${location && html`
${location}
`}
${summary && markdown(summary)} ${highlights.length > 0 && html`
    ${highlights.map(highlight => html`
  • ${markdown(highlight)}
  • `)}
`}
`, )}
`, )}
` ) }