Work history prelude and education

This commit is contained in:
Michal Vanko 2019-08-18 18:15:14 +02:00
parent ea26f5fed9
commit da0b5d2b86
4 changed files with 62 additions and 6 deletions

View File

@ -0,0 +1,10 @@
<script>
export let work
</script>
<article>
<h3>{work.name}</h3>
<section class="description">
{@html work.description}
</section>
</article>

View File

@ -14,16 +14,30 @@ export async function get(req, res, next) {
} }
const parsed = fm(pageSource) const parsed = fm(pageSource)
const projects = (parsed.attributes.projects || []).map(project => ({ const workHistory = (parsed.attributes.work_history || []).map(parseField('description'))
...project, const projects = (parsed.attributes.projects || [])
description: marked(project.description) .filter(project => project.displayed)
})) .map(parseField('description'))
const education = (parsed.attributes.education || [])
.filter(education => education.displayed)
.map(parseField('description'))
const response = { const response = {
title: parsed.attributes.title, title: parsed.attributes.title,
body: marked(parsed.body), body: marked(parsed.body),
workHistoryPrelude: marked(parsed.attributes.work_history_prelude),
workHistory,
projects, projects,
education,
} }
res.setHeader('Content-Type', 'application/json') res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify(response)) res.end(JSON.stringify(response))
}
function parseField(field) {
return item => ({
...item,
[field]: marked(item[field])
})
} }

View File

@ -9,7 +9,7 @@
</script> </script>
<script> <script>
import Workhistory from '../../components/portfolio/workhistory.svelte'; import Work from '../../components/portfolio/work.svelte';
import Project from '../../components/portfolio/project.svelte'; import Project from '../../components/portfolio/project.svelte';
export let content export let content
@ -27,7 +27,19 @@
{@html content.body} {@html content.body}
</section> </section>
<Workhistory /> <section class="work-history">
<h2>Work experience</h2>
<section class="work-history-prelude">
{@html content.workHistoryPrelude}
</section>
<ul>
{#each content.workHistory as work}
<li>
<Work work={work} />
</li>
{/each}
</ul>
</section>
<section class="projects"> <section class="projects">
<h2>Projects</h2> <h2>Projects</h2>
@ -39,3 +51,14 @@
{/each} {/each}
</ul> </ul>
</section> </section>
<section class="education">
<h2>Education</h2>
<ul>
{#each content.education as work}
<li>
<Work work={work} />
</li>
{/each}
</ul>
</section>

View File

@ -28,6 +28,7 @@ collections:
fields: fields:
- { label: Title, name: title, widget: string } - { label: Title, name: title, widget: string }
- { label: Body, name: body, widget: markdown } - { label: Body, name: body, widget: markdown }
- { label: Work history prelude, name: work_history_prelude, widget: markdown }
- label: Work history - label: Work history
name: work_history name: work_history
widget: list widget: list
@ -39,6 +40,7 @@ collections:
widget: list widget: list
fields: fields:
- { label: Project name, name: name, widget: string } - { label: Project name, name: name, widget: string }
- { label: Displayed, name: displayed, widget: boolean, default: true }
- { label: Description, name: description, widget: markdown } - { label: Description, name: description, widget: markdown }
- label: Image - label: Image
name: image name: image
@ -46,4 +48,11 @@ collections:
fields: fields:
- { label: Source, name: source, widget: image, required: false } - { label: Source, name: source, widget: image, required: false }
- { label: Image description, name: image_description, widget: string, required: false } - { label: Image description, name: image_description, widget: string, required: false }
- label: Education
name: education
widget: list
fields:
- { label: Institution, name: name, widget: string }
- { label: Displayed, name: displayed, widget: boolean, default: true }
- { label: Description, name: description, widget: markdown }