Skip to content

<ContentRenderer> default slot problem? #1459

@farnabaz

Description

@farnabaz

Discussed in #1448

Originally posted by kjanusz August 14, 2022

I have the problem that the representation of data in default slot does not work.
I searched issues but found nothing.

Am I doing something wrong? My mistake of thinking?


This works (title is displayed)

<template>
    <main>
        <h1>{{ data.title }}</h1>
        <ContentRenderer :value="data">
            <template #empty>
                <p>No content found.</p>
            </template>
        </ContentRenderer>
    </main>
</template>

<script setup lang="ts">
const { path } = useRoute();
const { data } = await useAsyncData(`content-${path}`, () => queryContent().where({ _path: path, draft: { $ne: true } }).findOne())
</script>

This does not work (title is not displayed)

<template>
    <main>
        <ContentRenderer :value="data">
            <h1>{{ data.title }}</h1>
            <template #empty>
                <p>No content found.</p>
            </template>
        </ContentRenderer>
    </main>
</template>

<script setup lang="ts">
const { path } = useRoute();
const { data } = await useAsyncData(`content-${path}`, () => queryContent().where({ _path: path, draft: { $ne: true } }).findOne())
</script>

My configuration

"devDependencies": {
    "@nuxt/content": "^2.0.1",
    "nuxt": "3.0.0-rc.8",
  }
export default defineNuxtConfig({
  // static HTML generation (SSG)
  ssr: true,
  target: "static",

  modules: ["@nuxt/content"],
  content: {
    // https://content.nuxtjs.org/api/configuration
  },
});

Bug or Feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions