This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/routes/blog.vue

43 lines
1.1 KiB
Vue
Raw Normal View History

2020-11-13 13:57:23 -08:00
<template>
<NotFound v-if="!content"/>
<div v-else class="container blog-post">
<div v-html="content"></div>
</div>
</template>
<script>
import { head } from "../src/helpers";
export default {
async asyncData({route}) {
try {
const content = (await import(`../locale/pl/blog/${route.params.slug}.md`)).default;
2020-11-23 08:41:12 -08:00
const titleMatch = content.match('<h1[^>]*>([^<]+)</h1>');
const title = titleMatch ? titleMatch[1] : null;
const imgMatch = content.match('<img src="([^"]+)"[^>]*>');
const img = imgMatch ? imgMatch[1] : null;
2020-11-13 13:57:23 -08:00
return {
content,
title,
2020-11-13 14:09:18 -08:00
img,
2020-11-13 13:57:23 -08:00
}
} catch {
return {};
}
},
head() {
return head({
title: this.title,
2020-11-13 14:09:18 -08:00
banner: this.img,
2020-11-13 13:57:23 -08:00
});
},
};
</script>
<style lang="scss">
.blog-post img {
max-width: 100%;
}
</style>