Svelte kit transition

This commit is contained in:
2021-04-24 18:24:17 +02:00
parent 59db328b4b
commit 58347b9ca6
29 changed files with 3451 additions and 7180 deletions

View File

@@ -22,14 +22,15 @@ export interface PortfolioAttributes {
education: RecordAttributes[]
}
export async function get(req, res, next) {
export async function get() {
let pageSource: string
try {
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
return {
status: 500,
body: 'Error loading portfolio source file. \n' + e.toString(),
}
}
const parsed = fm<PortfolioAttributes>(pageSource)
@@ -52,6 +53,8 @@ export async function get(req, res, next) {
education,
}
res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify(response))
return {
status: 200,
body: response,
}
}

View File

@@ -1,9 +1,14 @@
<script context="module">
export async function preload() {
const res = await this.fetch('portfolio.json')
/**
* @type {import('@sveltejs/kit').Load}
*/
export async function load({ fetch }) {
const res = await fetch('portfolio.json')
const content = await res.json()
return {
content,
props: {
content,
}
}
}
</script>