search stuffs

This commit is contained in:
2021-07-03 00:04:27 +05:00
parent bcb27fc265
commit 1647965d46
19 changed files with 62604 additions and 93 deletions

36
resources/js/search.js vendored Normal file
View File

@@ -0,0 +1,36 @@
export default function (meilisearchConfig, index, searchOptions) {
const defaultSearchOptiobns = {
limit: 10,
};
searchOptions = { ...defaultSearchOptiobns, ...searchOptions };
return {
query: "",
index: null,
results: null,
watchQuery() {
this.$watch("query", (query) => {
if (query == "") {
this.results = null;
return;
}
this.search(query);
});
},
async search(query) {
this.results = await this.index.search(query, searchOptions);
},
init() {
const client = new window.MeiliSearch(meilisearchConfig);
this.index = client.index(index);
this.watchQuery();
},
};
}