Skip to content

Commit

Permalink
docs: add example of additional sorting options for queryContent (#2042)
Browse files Browse the repository at this point in the history

Co-authored-by: nobkd <44443899+nobkd@users.noreply.github.com>
  • Loading branch information
james-tyner and nobkd committed Apr 28, 2023
1 parent 7da9b28 commit 79d5181
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/content/4.api/2.composables/1.query-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ const articles = await queryContent('articles')

```

> `sort()`{lang="ts"} method does **case-sensitive** sort by default. There is some magical options you can pass to sort options to change sort behavior, like sorting **case-insensitive**.
> `sort()`{lang="ts"} method does **case-sensitive, alphabetical** sort by default. There is some magical options you can pass to sort options to change sort behavior, like sorting **case-insensitive** or **numerically rather than alphabetically**.
>
> - `$sensitivity`{lang=ts}: Change case sensitivity. Like using `$sensitivity: 'base'`{lang=ts} for case-insensitive sort
> - `$numeric`{lang=ts}: Boolean whether numeric collation should be used, such that `"1" < "2" < "10"`.
> - `$caseFirst`{lang=ts}: Whether upper case or lower case should sort first.
For example, to sort a list of people from youngest to oldest:
```ts
const people = await queryContent('people')
.sort({ age: 1, $numeric: true })
.find()
```

These options are given to [Intl.Collator()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#parameters).

## `limit(count)`
Expand Down

0 comments on commit 79d5181

Please sign in to comment.