orchidhq / Orchid

Build and deploy beautiful documentation sites that grow with you
https://orchid.run
GNU General Public License v3.0
517 stars 53 forks source link

Split Search Javascript file into a library and a separate widget #174

Open cjbrooks12 opened 6 years ago

cjbrooks12 commented 6 years ago

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.