From da0b5d2b8665ccd93a521ba490fa743ea2f2200f Mon Sep 17 00:00:00 2001 From: Michal Vanko Date: Sun, 18 Aug 2019 18:15:14 +0200 Subject: [PATCH] Work history prelude and education --- src/components/portfolio/work.svelte | 10 ++++++++++ src/routes/portfolio/index.json.js | 22 ++++++++++++++++++---- src/routes/portfolio/index.svelte | 27 +++++++++++++++++++++++++-- static/admin/config.yml | 9 +++++++++ 4 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 src/components/portfolio/work.svelte diff --git a/src/components/portfolio/work.svelte b/src/components/portfolio/work.svelte new file mode 100644 index 0000000..3838fa5 --- /dev/null +++ b/src/components/portfolio/work.svelte @@ -0,0 +1,10 @@ + + +
+

{work.name}

+
+ {@html work.description} +
+
\ No newline at end of file diff --git a/src/routes/portfolio/index.json.js b/src/routes/portfolio/index.json.js index cd1d31d..9b7b3f6 100644 --- a/src/routes/portfolio/index.json.js +++ b/src/routes/portfolio/index.json.js @@ -14,16 +14,30 @@ export async function get(req, res, next) { } const parsed = fm(pageSource) - const projects = (parsed.attributes.projects || []).map(project => ({ - ...project, - description: marked(project.description) - })) + const workHistory = (parsed.attributes.work_history || []).map(parseField('description')) + const projects = (parsed.attributes.projects || []) + .filter(project => project.displayed) + .map(parseField('description')) + const education = (parsed.attributes.education || []) + .filter(education => education.displayed) + .map(parseField('description')) + const response = { title: parsed.attributes.title, body: marked(parsed.body), + workHistoryPrelude: marked(parsed.attributes.work_history_prelude), + workHistory, projects, + education, } res.setHeader('Content-Type', 'application/json') res.end(JSON.stringify(response)) +} + +function parseField(field) { + return item => ({ + ...item, + [field]: marked(item[field]) + }) } \ No newline at end of file diff --git a/src/routes/portfolio/index.svelte b/src/routes/portfolio/index.svelte index 125efad..224584e 100644 --- a/src/routes/portfolio/index.svelte +++ b/src/routes/portfolio/index.svelte @@ -9,7 +9,7 @@