You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/3.utils/2.query-collection-navigation.md
+68-2Lines changed: 68 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,18 +6,31 @@ description: 'The queryCollectionNavigation composable generates the navigation
6
6
## Type
7
7
8
8
```ts
9
-
function queryCollectionNavigation<TextendskeyofPageCollections>(collection:T, fields?:Array<keyofPageCollections[T]>):Promise<ContentNavigationItem[]>
9
+
function queryCollectionNavigation<TextendskeyofPageCollections>(
Use the auto-imported `queryCollectionNavigation` to generate a navigation tree for a specific collection. This is particularly useful for creating dynamic navigation menus or sidebars based on your content structure.
15
25
26
+
The function returns a chainable promise that allows you to add additional query conditions:
16
27
17
28
```vue [pages/[...slug\\].vue]
18
29
<script setup lang="ts">
19
30
const { data } = await useAsyncData('navigation', () => {
20
31
return queryCollectionNavigation('docs')
32
+
.where('published', '==', true)
33
+
.order('date', 'DESC')
21
34
})
22
35
</script>
23
36
```
@@ -32,6 +45,59 @@ Generate a navigation tree for the specified collection.
32
45
-`collection`: The key of the defined collection in `content.config.ts`.
33
46
-`extraFields`: (Optional) An array of additional fields to include in the navigation items. (By default `title` and `path` are included in the navigation items.)
- Returns: A chainable promise that resolves to a navigation tree structure. The promise includes methods for adding query conditions:
49
+
-`where(field, operator, value)`: Add a WHERE condition
50
+
-`andWhere(groupFactory)`: Add a grouped AND condition
51
+
-`orWhere(groupFactory)`: Add a grouped OR condition
52
+
-`order(field, direction)`: Add an ORDER BY clause
36
53
37
54
The navigation tree is generated based on the directory structure and ordering happens based on files [ordering](/docs/collections/types#ordering-files)
55
+
56
+
## Examples
57
+
58
+
Basic usage without additional query conditions:
59
+
60
+
```vue [pages/[...slug].vue]
61
+
<script setup lang="ts">
62
+
const { data } = await useAsyncData('navigation', () => {
Copy file name to clipboardExpand all lines: docs/content/docs/3.utils/3.query-collection-item-surroundings.md
+51-7Lines changed: 51 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,32 @@ description: 'The queryCollectionItemSurroundings composable looks for sibling c
6
6
## Type
7
7
8
8
```ts
9
-
function queryCollectionItemSurroundings<TextendskeyofPageCollections>(collection:T, path:string, opts?:SurroundOptions<keyofPageCollections[T]>):Promise<ContentNavigationItem[]>
9
+
function queryCollectionItemSurroundings<TextendskeyofPageCollections>(
Use the auto-imported `queryCollectionItemSurroundings` to find the previous and next items relative to a specific content item in a collection. This is particularly useful for creating navigation between related content pages.
15
26
16
-
```vue [pages/[...slug\\].vue]
27
+
The function returns a chainable promise that allows you to add additional query conditions:
28
+
29
+
```vue [pages/[...slug].vue]
17
30
<script setup lang="ts">
18
31
const { data } = await useAsyncData('surround', () => {
0 commit comments