Skip to content

Commit 0588ca9

Browse files
committed
Add css template and html playground
1 parent b257bb8 commit 0588ca9

File tree

6 files changed

+5553
-0
lines changed

6 files changed

+5553
-0
lines changed

playgrounds/html/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.parcel_cache/

playgrounds/html/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# MeiliSearch Simple Game Search
2+
3+
This repository is a **playground**, all the following files are hot-reloading:
4+
- _ROOT_/src/*
5+
- _ROOT_/template/basic_search.css
6+
- ./public/index.html
7+
8+
meaning you can change the code of this demo but also `instant-meilisearch` and it will hot reload (if you run it with `yarn serve`).
9+
10+
The main purpose of this example is to showcase that instant-meilisearch can be easely included in an existing front-end application using `<script>` tags.
11+
12+
The demo in this directory showcases a basic search that will let you search through games names.
13+
14+
[![Nobel prices demo](asset/stardew.gif)](https://nobel.meilisearch.com)
15+
16+
## Project setup
17+
18+
```bash
19+
$ yarn install
20+
```
21+
22+
### Compiles and hot-reloads for development
23+
```
24+
yarn serve
25+
```
26+
27+
### Compiles and minifies for production
28+
```
29+
yarn build
30+
```
31+
32+
### Customize configuration
33+
See [Configuration Reference](https://cli.vuejs.org/config/).
34+
35+
36+
💡 If you have never used InstantSearch, we recommend reading this [getting started documentation](https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/).

playgrounds/html/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "web",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"start": "parcel serve ./public/index.html --global instantMeiliSearch --open",
9+
"build": "parcel build ./public/index.html --global instantMeiliSearch"
10+
},
11+
"browserslist": [
12+
"last 3 and_chr versions",
13+
"last 3 chrome versions",
14+
"last 3 opera versions",
15+
"last 3 ios_saf versions",
16+
"last 3 safari versions"
17+
],
18+
"author": "",
19+
"license": "ISC",
20+
"dependencies": {},
21+
"devDependencies": {
22+
"@babel/core": "^7.12.10",
23+
"parcel-bundler": "^1.12.4"
24+
}
25+
}

playgrounds/html/public/index.html

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<!--
6+
To use this browser build, please change the following stylesheet tag with this CDN
7+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@meilisearch/instant-meilisearch/templates/basic_search.css" />
8+
-->
9+
<link rel="stylesheet" href="../../../templates/basic_search.css" />
10+
</head>
11+
<body>
12+
<div class="wrapper">
13+
<div id="searchbox" focus></div>
14+
<div id="hits"></div>
15+
</div>
16+
<!--
17+
To use this browser build, please change the following script tag with this CDN
18+
<script src="https://cdn.jsdelivr.net/npm/@meilisearch/instant-meilisearch/dist/instant-meilisearch.umd.min.js"></script>
19+
-->
20+
<script src="../../../src/index.js"></script>
21+
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4"></script>
22+
<script>
23+
console.log(instantMeiliSearch)
24+
instantMeiliSearch = instantMeiliSearch.default
25+
const search = instantsearch({
26+
indexName: "steam-video-games",
27+
searchClient: instantMeiliSearch(
28+
"https://demos.meilisearch.com",
29+
"dc3fedaf922de8937fdea01f0a7d59557f1fd31832cb8440ce94231cfdde7f25",
30+
)
31+
});
32+
search.addWidgets([
33+
instantsearch.widgets.searchBox({
34+
container: "#searchbox",
35+
placeholder: "Search..",
36+
}),
37+
instantsearch.widgets.configure({
38+
hitsPerPage: 8,
39+
}),
40+
instantsearch.widgets.hits({
41+
container: "#hits",
42+
templates: {
43+
item: `
44+
<div>
45+
<div class="hit-name">
46+
{{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}}
47+
</div>
48+
</div>
49+
`
50+
}
51+
})
52+
]);
53+
54+
search.start();
55+
</script>
56+
</body>
57+
</html>
58+

0 commit comments

Comments
 (0)