Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 26d7197

Browse files
authored
docs: use useAsyncData
1 parent bb866ef commit 26d7197

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

docs/content/docs/3.files/2.yaml.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,20 @@ url: https://github.com/larbish
4646
4747
Now we can query authors:
4848
49-
```ts
49+
```vue
50+
<script lang="ts" setup>
5051
// Find a single author
51-
const theAuthor = await queryCollection('authors')
52-
.where('stem', '=', 'larbish')
53-
.first()
52+
const { data: author } = await useAsyncData('larbish', () => {
53+
return queryCollection('authors')
54+
.where('stem', '=', 'larbish')
55+
.first()
56+
})
5457

5558
// Get all authors
56-
const authors = await queryCollection('authors')
57-
.order('name', 'DESC')
58-
.all()
59+
const { data: authors } = await useAsyncData('authors', () => {
60+
return queryCollection('authors')
61+
.order('name', 'DESC')
62+
.all()
63+
})
64+
</script>
5965
```

0 commit comments

Comments
 (0)