By splitting the Search Javascript file into a library component and a widget component, it will be easier to implement into themes.
The library encapsulates all the functionality of fetching the local site's JSON indices and booting up lunr.js. It provides a simple public API for loading and querying data, and returns a list of results that can be used in any front-end framework.
The widget component should include the library component, and provide a fully-encapsulated search solution. By attaching the widget to any existing form element, when the form is submitted it will load the results into a dropdown and provide basic, default styling for it. This widget will not be designed to be customized for the theme. Rather, if custom styling is desired, then the theme should write its own search component using the search library. It shouldn't be too difficult.
In addition, I would like to re-write this component using Kotlin/JS. The widget might be re-written in VueJS, rather than JQuery or vanilla JS.
By splitting the Search Javascript file into a library component and a widget component, it will be easier to implement into themes.
The library encapsulates all the functionality of fetching the local site's JSON indices and booting up lunr.js. It provides a simple public API for loading and querying data, and returns a list of results that can be used in any front-end framework.
The widget component should include the library component, and provide a fully-encapsulated search solution. By attaching the widget to any existing
form
element, when the form is submitted it will load the results into a dropdown and provide basic, default styling for it. This widget will not be designed to be customized for the theme. Rather, if custom styling is desired, then the theme should write its own search component using the search library. It shouldn't be too difficult.In addition, I would like to re-write this component using Kotlin/JS. The widget might be re-written in VueJS, rather than JQuery or vanilla JS.