The <ContentList> component fetches a list of documents and allows you to render them by using slots.
The fetching path defaults to the content root (/).
An explicit path can be given to the component.
<template>
<main>
<ContentList path="/articles" v-slot="{ list }">
<div v-for="article in list" :key="article._path">
<h2>{{ article.title }}</h2>
<p>{{ article.description }}</p>
</div>
</ContentList>
</main>
</template>
path: The path of the content to load from content source.
string'/'query: A query builder params object to be passed to <ContentQuery /> component.
QueryBuilderParamsundefineddefault slot can be used to render the content via v-slot="{ list }" syntax:
<template>
<main>
<ContentList path="/articles" v-slot="{ list }">
<div v-for="article in list" :key="article._path">
<h2>{{ article.title }}</h2>
<p>{{ article.description }}</p>
</div>
</ContentList>
</main>
</template>
not-found slot can be used when no documents are matching the query:
<template>
<main>
<ContentList path="/articles">
<template #default="{ list }">
<!-- ...default slot -->
</template>
<template #not-found>
<p>No articles found.</p>
</template>
</ContentList>
</main>
</template>
<script setup lang="ts">
import type { QueryBuilderParams } from '@nuxt/content/dist/runtime/types'
const query: QueryBuilderParams = { path: '/articles', where: [{ layout: 'article' }], limit: 5, sort: [{ date: -1 }] }
</script>
<template>
<main>
<ContentList :query="query" v-slot="{ list }">
<div v-for="article in list" :key="article._path">
<h2>{{ article.title }}</h2>
<p>{{ article.description }}</p>
</div>
</ContentList>
</main>
</template>
[
{
"title": "<ContentRenderer>",
"path": "/content-v2/components/content-renderer",
"stem": "content-v2/4.components/2.content-renderer",
"description": "Takes your component from an AST to a wonderful template."
},
{
"title": "<ContentNavigation>",
"path": "/content-v2/components/content-navigation",
"stem": "content-v2/4.components/3.content-navigation",
"description": "Building complex navigation from your content has never been easier."
}
]