Skip to content

Commit ef2a65c

Browse files
committed
Add code sample for landing page
1 parent 0e27187 commit ef2a65c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.code-samples.meilisearch.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
landing_getting_started_1: |-
2+
// in app.js
3+
const search = instantsearch({
4+
indexName: 'movies',
5+
searchClient: instantMeiliSearch(
6+
'http://localhost:7700',
7+
'searchKey'
8+
),
9+
})
10+
11+
search.addWidgets([
12+
instantsearch.widgets.searchBox({
13+
container: '#searchbox',
14+
}),
15+
instantsearch.widgets.hits({
16+
container: '#hits',
17+
templates: {
18+
item: `
19+
<div>
20+
<div class="hit-name">
21+
{{#helpers.highlight}}{ "attribute": "title" }{{/helpers.highlight}}
22+
</div>
23+
</div>
24+
`,
25+
},
26+
}),
27+
])
28+
search.start()
29+
30+
// in index.html
31+
<!DOCTYPE html>
32+
<html lang="en">
33+
<head>
34+
<meta charset="utf-8" />
35+
</head>
36+
37+
<body>
38+
<div>
39+
<div id="searchbox"></div>
40+
<div id="hits"></div>
41+
</div>
42+
43+
<script src="https://cdn.jsdelivr.net/npm/@meilisearch/instant-meilisearch/dist/instant-meilisearch.umd.min.js"></script>
44+
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4"></script>
45+
<script src="./app.js"></script>
46+
</body>
47+
</html>

0 commit comments

Comments
 (0)