vue-instantsearch-ssr
Version:
👀 Lightning-fast Algolia search for Vue apps
44 lines (41 loc) • 1.07 kB
JavaScript
import { createSuitMixin } from '../mixins/suit';
import { createWidgetMixin } from '../mixins/widget';
import indexWidget from 'instantsearch.js/es/widgets/index/index';
import { renderCompat, getDefaultSlot } from '../util/vue-compat';
// wrapped in a dummy function, since indexWidget doesn't render
const connectIndex = () => indexWidget;
export default {
name: 'AisIndex',
mixins: [
createSuitMixin({ name: 'Index' }),
createWidgetMixin({ connector: connectIndex }),
],
provide() {
return {
// The widget is created & registered by widgetMixin, accessor is needed
// because provide is not reactive.
$_ais_getParentIndex: () => this.widget,
};
},
props: {
indexName: {
type: String,
required: true,
},
indexId: {
type: String,
required: false,
},
},
render: renderCompat(function(h) {
return h('div', {}, getDefaultSlot(this));
}),
computed: {
widgetParams() {
return {
indexName: this.indexName,
indexId: this.indexId,
};
},
},
};