Adventures with Nuxt3: Creating a simple blog
/ 83
import {useDateFormat} from '@vueuse/core'
export default {
async setup() {
const {path} = useRoute()
const {data: post} = await useAsyncData(`content-${path}`, () => {
return queryContent().where(
{
_path: path,
}).findOne()
})
console.log('path', path)
console.log('post', post)
return {
useDateFormat,
post
}
},
computed: {
formattedDate() {
return useDateFormat(this.post.date, 'YYYY-MM-DD h:mm aa', {locales: 'en-US'}).value
}
}
}