diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/kronika/_year/_month/_day/_title/index.vue | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/pages/kronika/_year/_month/_day/_title/index.vue b/pages/kronika/_year/_month/_day/_title/index.vue index 9fab1d0..7990abe 100644 --- a/pages/kronika/_year/_month/_day/_title/index.vue +++ b/pages/kronika/_year/_month/_day/_title/index.vue @@ -11,42 +11,48 @@ </template> <script> -const md = require('markdown-it')() -import frontmatter from 'front-matter' -import k from '~/api' +import axios from 'axios' export default { head() { - return { - meta: [ - { - hid: 'og:title', - property: 'og:title', - content: this.attributes.title - }, - { - hid: 'og:type', - property: 'og:type', - content: 'article' - }, - { - hid: 'og:article:author', - property: 'og:article:author', - content: this.attributes.author - } - ] + if (this.attributes) { + return { + meta: [ + { + hid: 'og:title', + property: 'og:title', + content: this.attributes.title + }, + { + hid: 'og:type', + property: 'og:type', + content: 'article' + }, + { + hid: 'og:article:author', + property: 'og:article:author', + content: this.attributes.author + } + ] + } } }, async asyncData({ params }) { const { year, month, day, title } = params - const post = k.getPost(year, month, day, title) + const response = await axios + .get( + `${process.env.baseUrl}/api/posts/${year}/${month}/${day}/${title}.json` + ) + .catch(err => ({ notFound: true })) + + const post = response.data if (post === undefined) return { notFound: true } return { params, - attributes: post.content.meta, - content: post.content.html + attributes: post.meta, + content: post.content } }, data() { |