lunasqu.ee-nuxt/pages/blog/[year]/[month]/[day]/[slug].vue

45 lines
1.4 KiB
Vue
Raw Permalink Normal View History

2022-10-16 09:37:13 +00:00
<template>
<NuxtLayout name="blog">
2022-10-16 11:04:03 +00:00
<Head>
<Meta name="description" :content="preview" />
<Meta property="og:type" content="article" />
<Meta property="og:title" content="Self-hosting, Part 1" />
<Meta
property="og:url"
:content="'https://lunasqu.ee/blog/' + post.fullSlug"
/>
<Meta property="og:site_name" content="Evert's Blog" />
<Meta property="og:description" :content="preview" />
<Meta property="og:locale" content="en_US" />
<Meta property="article:published_time" :content="isostamp" />
<Meta property="article:modified_time" :content="isostamp" />
<Meta property="article:author" content="Evert Prants" />
<Meta v-for="tag in post.tags" property="article:tag" :content="tag" />
<Meta name="twitter:card" content="summary" />
2022-10-16 12:50:21 +00:00
<Title>{{ post.title }} | Evert's Blog | lunasqu.ee</Title>
2022-10-16 11:04:03 +00:00
</Head>
2022-10-16 09:37:13 +00:00
<BlogPost :post="post" :detail="true" />
</NuxtLayout>
</template>
<script setup lang="ts">
2022-10-16 11:04:03 +00:00
import type { BlogPost } from '~~/lib/types/post';
2022-10-16 09:37:13 +00:00
const route = useRoute();
2022-10-16 11:34:04 +00:00
const { data: post } = await useFetch<BlogPost>(
`/api/blog/${route.params.slug}`,
{
key: `${route.params.slug}-post`,
}
2022-10-16 11:04:03 +00:00
);
const isostamp = computed(() => new Date(post.value.date).toISOString());
const preview = computed(() =>
post.value.html
.replace(/<[^>]*>?/gm, '')
.replace('\n', ' ')
.substring(0, 120)
);
2022-10-16 09:37:13 +00:00
</script>