Parse portfolio markdown and expose it as json
This commit is contained in:
@ -1,19 +0,0 @@
|
||||
<script>
|
||||
import Personal from '../components/portfolio/personal.svelte';
|
||||
import Skills from '../components/portfolio/skills.svelte';
|
||||
import Workhistory from '../components/portfolio/workhistory.svelte';
|
||||
import Projects from '../components/portfolio/projects.svelte';
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Portfolio - Michal Vanko</title>
|
||||
</svelte:head>
|
||||
|
||||
<h1>Michal Vanko</h1>
|
||||
|
||||
<h2>Software Developer</h2>
|
||||
|
||||
<Personal />
|
||||
<Skills />
|
||||
<Workhistory />
|
||||
<Projects />
|
26
src/routes/portfolio/index.json.js
Normal file
26
src/routes/portfolio/index.json.js
Normal file
@ -0,0 +1,26 @@
|
||||
import { readFile } from 'fs'
|
||||
import { promisify } from 'util'
|
||||
import fm from 'front-matter'
|
||||
import marked from 'marked'
|
||||
|
||||
export async function get(req, res, next) {
|
||||
let pageSource
|
||||
try {
|
||||
console.log(process.cwd())
|
||||
pageSource = await promisify(readFile)('_pages/portfolio.md', 'utf-8')
|
||||
} catch (e) {
|
||||
res.statusCode = 500
|
||||
res.end('Error loading portfolio source file. \n' + e.toString())
|
||||
return
|
||||
}
|
||||
|
||||
const parsed = fm(pageSource)
|
||||
console.log(parsed)
|
||||
const response = {
|
||||
title: parsed.attributes.title,
|
||||
content: marked(parsed.attributes.content),
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.end(JSON.stringify(response))
|
||||
}
|
19
src/routes/portfolio/portfolio.svelte
Normal file
19
src/routes/portfolio/portfolio.svelte
Normal file
@ -0,0 +1,19 @@
|
||||
<script>
|
||||
import Personal from '../../components/portfolio/personal.svelte';
|
||||
import Skills from '../../components/portfolio/skills.svelte';
|
||||
import Workhistory from '../../components/portfolio/workhistory.svelte';
|
||||
import Projects from '../../components/portfolio/projects.svelte';
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Portfolio - Michal Vanko</title>
|
||||
</svelte:head>
|
||||
|
||||
<h1>Michal Vanko</h1>
|
||||
|
||||
<h2>Software Developer</h2>
|
||||
|
||||
<Personal />
|
||||
<Skills />
|
||||
<Workhistory />
|
||||
<Projects />
|
Reference in New Issue
Block a user