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/guide-search.md
+74-1Lines changed: 74 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,77 @@
1
-
# Add search to Gridsome
1
+
# Add a search to Gridsome
2
+
3
+
## Using local GraphQL data
4
+
5
+
Adding dynamic search functionality to your static site is a breeze. We can use Vue's reactive system in such scenarios.
6
+
7
+
Take the following query as an example:
8
+
9
+
```graphql
10
+
{
11
+
allPost {
12
+
edges {
13
+
node {
14
+
title
15
+
excerpt
16
+
date
17
+
path
18
+
}
19
+
}
20
+
}
21
+
}
22
+
```
23
+
24
+
We would like to retrieve only posts that match what the user enters in the input field. So let's start by creating a `search` variable that will hold this value:
25
+
26
+
```js
27
+
data() {
28
+
return {
29
+
search:''
30
+
}
31
+
}
32
+
```
33
+
34
+
We can benefit from a computed property to filter the query results before passing the data further:
0 commit comments