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

Skip to content

Commit b2ba96c

Browse files
authored
docs: use useAsyncData in json page
1 parent 26d7197 commit b2ba96c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

docs/content/docs/3.files/3.json.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,20 @@ Each file in `data` collection should contain only one object, therefore having
5454

5555
Now we can query authors:
5656

57-
```ts
57+
```vue
58+
<script lang="ts" setup>
5859
// Find a single author
59-
const theAuthor = await queryCollection('authors')
60-
.where('stem', '=', 'larbish')
61-
.first()
60+
const { data: author } = await useAsyncData('larbish', () => {
61+
return queryCollection('authors')
62+
.where('stem', '=', 'larbish')
63+
.first()
64+
})
6265
6366
// Get all authors
64-
const authors = await queryCollection('authors')
65-
.order('name', 'DESC')
66-
.all()
67+
const { data: authors } = await useAsyncData('authors', () => {
68+
return queryCollection('authors')
69+
.order('name', 'DESC')
70+
.all()
71+
})
72+
</script>
6773
```

0 commit comments

Comments
 (0)