Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<ContentRenderer> default slot problem? #1459

Closed
farnabaz opened this issue Aug 17, 2022 Discussed in #1448 · 0 comments · Fixed by #1460
Closed

<ContentRenderer> default slot problem? #1459

farnabaz opened this issue Aug 17, 2022 Discussed in #1448 · 0 comments · Fixed by #1460

Comments

@farnabaz
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant