When loading fetch rendered markdown from api.

This commit is contained in:
2021-01-03 18:18:31 +01:00
parent a79965765e
commit 31c1ec1820

View File

@@ -5,7 +5,8 @@
<p>{{ post.date }} by {{ post.author }}</p>
</header>
<article>
<article class="markdown-body">
<p v-html="markdown" v-if="markdown"></p>
<img :src="post.thumbnail" />
<p v-html="post.description"></p>
@@ -19,7 +20,9 @@ import { humanReadableDate } from "@/utils";
export default {
data() {
return {
markdown: undefined,
post: {
id: 1,
title: "Building (another) NAS.",
date: humanReadableDate(new Date()),
author: "Kevin",
@@ -32,6 +35,16 @@ A lot has changed in my life over the last 6 months or so, moving out of my flat
<p>Join me on my newest endeavour to build a new NAS, or dont of course.</p>`
}
}
},
created() {
this.fetchMarkdown();
},
methods: {
fetchMarkdown() {
fetch(`/api/post/${this.post.id}/render`)
.then(resp => resp.json())
.then(response => this.markdown = response.markdown)
}
}
}
</script>