Public archive for the Return to Ritherdon project. https://www.nicolaellisandritherdon.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

97 lines
2.3 KiB

/**
Full Search
================================================================================
This file's main focus in providing the Meilisearch features to the
search/index.html template.
For more information on Meilisearch, use:
- https://docs.meilisearch.com/
- https://github.com/meilisearch/instant-meilisearch
Meilisearch provides an 'InstantSearch' add-on (plug-in?) which
links the Meilisearch instance you have running to this website (link above for
more information).
*/
let server = "";
let apiKey = "";
if (location.hostname === "localhost"
|| location.hostname === "127.0.0.1"
|| location.hostname === "beta.nera.com") {
server = "http://localhost:7700";
apiKey= "meilisearch-beta-key";
} else {
server = "https://www.nera.net";
apiKey = "meilisearch-production-key-nera";
}
const search = instantsearch({
indexName: "nera",
searchClient: instantMeiliSearch(
server,
apiKey,
{
primaryKey: 'id',
}
)
});
search.addWidgets([
instantsearch.widgets.searchBox({
container: "#searchbox",
placeholder: "Search...",
}),
instantsearch.widgets.clearRefinements({
container: "#clear-refinements"
}),
instantsearch.widgets.refinementList({
container: "#year-list",
attribute: "year"
}),
instantsearch.widgets.refinementList({
container: "#month-list",
attribute: "month"
}),
instantsearch.widgets.refinementList({
container: "#keywords-list",
attribute: "keywords"
}),
instantsearch.widgets.configure({
hitsPerPage: 30,
snippetEllipsisText: "...",
attributesToSnippet: ["title:100"]
}),
instantsearch.widgets.hits({
container: "#hits",
templates: {
item: `
<a class="ui-link-card" href="{{server}}/{{relative-path}}">
<div>
<img src="{{server}}/{{thumbnail-path}}"/>
<div class="ui-card-text">
<span class="ui-card-title">
{{#helpers.highlight}}{"attribute": "title"}{{/helpers.highlight}}
</span>
<span class="ui-card-secondary">
{{#helpers.highlight}}{"attribute": "year"}{{/helpers.highlight}}
</span>
<span class="ui-card-secondary">
{{#helpers.highlight}}{"attribute": "month"}{{/helpers.highlight}}
</span>
<span class="ui-card-keywords">
{{keywords}}
</span>
</div>
</div>
</a>
`
}
}),
instantsearch.widgets.pagination({
container: "#pagination"
})
]);
search.start();