Skip to content

Commit

Permalink
docs: update findSurround usage (#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Oct 19, 2022
1 parent 3b22612 commit d0d7ccd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/content/4.api/2.composables/1.query-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,23 @@ const firstArticle = await queryContent('articles').findOne()
- Type: `{ before: number, after: number }`{lang=ts}
- Default: `{ before: 1, after: 1 }`{lang=ts}

Get previous and next results around a specific path.
Get previous and next results around the path. The path should be full path of the target content.

You will always obtain an array of fixed length filled with the matching document or null.

```ts
const [prev, next] = await queryContent('articles')
const [prev, next] = await queryContent()
.only(['_path', 'title'])
.sort({ date: 1})
.where({ isArchived: false })
.findSurround('article-2')
.findSurround('/articles/article-2')

// Returns
[
{
title: 'Article 1',
path: 'article-1'
_path: '/articles/article-1'
//...
},
null // no article-3 here
]
Expand Down

0 comments on commit d0d7ccd

Please sign in to comment.