Skip to content

Commit

Permalink
feat(Blog Slug): ✨ Use API To parse markdown instead of using browser
Browse files Browse the repository at this point in the history
  • Loading branch information
bKoZii committed Sep 12, 2024
1 parent f841e5d commit 321d00b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pages/blog/[slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
<script lang="ts" setup>
import type { RouteLocationNormalized } from 'vue-router'
import type { StrapiBlogSlug } from '~/types/StrapiBlogSlug'
import { parseMarkdown } from '@nuxtjs/mdc/runtime'
import type { MDCParserResult } from '@nuxtjs/mdc'
const { findOne } = useStrapi()
const route: RouteLocationNormalized = useRoute()
const { data:blogSlug } = await useAsyncData('blogSlug', () =>
findOne<StrapiBlogSlug>('blogs', route.params['slug'] as string, {
findOne<StrapiBlogSlug>('blogs', route.params.slug as string, {
fields: ['title', 'subtitle', 'publishedAt', 'slug', 'content', 'updatedAt', 'createdAt'],
populate: {
mainImage: {
Expand All @@ -52,9 +50,14 @@ useSeoMeta({
ogUrl: `https://konkamon.live/blog/${blogSlug.value?.slug}`
})
definePageMeta({
middleware: ['check-blog-post']
})
definePageMeta({
middleware: ['check-blog-post']
})
const { data: ast } = await useAsyncData<MDCParserResult>('markdown', () => parseMarkdown(blogSlug.value?.content))
const { data: ast } = await useFetch('/api/mdc-transform', {
method: 'POST',
body: {
content: blogSlug.value?.content
}
})
</script>

1 comment on commit 321d00b

@vercel
Copy link

@vercel vercel bot commented on 321d00b Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

konkamon – ./

konkamon.vercel.app
konkamon-bkozii.vercel.app
konkamon-git-main-bkozii.vercel.app

Please sign in to comment.