#My content component disappears on refresh

2 messages · Page 1 of 1 (latest)

honest tree
#

Hi all, I have a content component that shows title and publish date of my blog posts but it disappears on refresh. I'm using document-driven mode:

<script setup lang="ts">
const { page } = useContent()
function formatDate(date) {
  return new Date(date).toLocaleDateString('en', {
    year: 'numeric',
    month: 'short',
    day: 'numeric',
  })
}   
</script>

<template>
  <div>
    <h1 class="!mb-0">{{ page.title }}</h1>
    <p class="m-0 !my-0 text-left text-sm md:text-lg text-stone-500">
      {{ formatDate(page.createdAt) }}
    </p>
    <div class="flex mt-4">
    <div v-for="(tag, index) in page.tag" :key="index" class="mr-2 bg-primary-dark text-sm py-0.5 px-2.5 shadow rounded-full lowercase text-stone-300 opacity-60">{{ tag }}</div>
    </div>
  </div>
</template>

And in nuxt.config my content section is:

content: {
  documentDriven: true
},

Any idea why this would happen (I'm doing something wrong obviously)?

honest tree
#

I forgot to mention my folder strucutre:

-components
-- content
--- PublishDate.vue

-content
-- blog
--- mypost.md

-pages
-- blog
--- [...slug].vue
--- index.vue

and in nuxt.config I simply have:

content: {
  documentDriven: true
},