Skip to content

Commit

Permalink
docs(content-list): Updated query reference and added example (#1548)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
  • Loading branch information
2 people authored and farnabaz committed Oct 19, 2022
1 parent 186e463 commit 5102eeb
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion docs/content/4.api/1.components/2.content-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ An explicit `path`{lang=ts} can be given to the component.
- `path`{lang=ts}: The path of the content to load from content source.
- Type: `String`{lang=ts}
- Default: `'/'`{lang=ts}
- `query`{lang=ts}: A query to be passed to `queryContent()`.
- `query`{lang=ts}: A query builder params object to be passed to `<ContentQuery />` component.
- Type: `QueryBuilderParams`{lang=ts}
- Default: `undefined`{lang=ts}

Expand Down Expand Up @@ -48,3 +48,23 @@ An explicit `path`{lang=ts} can be given to the component.
</main>
</template>
```

## Query example

```html [pages/index.vue]
<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>
```

0 comments on commit 5102eeb

Please sign in to comment.