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

docs(content-list): Updated query reference and added example #1548

Merged
merged 3 commits into from
Sep 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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";
Atinux marked this conversation as resolved.
Show resolved Hide resolved
const query: QueryBuilderParams = { path: '/articles', where: { layout: 'article' }, limit: 5, sort: { date: -1 } };
Atinux marked this conversation as resolved.
Show resolved Hide resolved
</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>
```