cozydev-pink / protosearch

prototype search library in pure scala
https://cozydev-pink.github.io/protosearch/
Apache License 2.0
9 stars 5 forks source link

Add prototype sbt plugin for `laikaSite` integration #148

Closed valencik closed 8 months ago

valencik commented 9 months ago

This PR adds a sbt plugin, "protosearch-sbt", for generating an index of site documentation.

addSbtPlugin("pink.cozydev" % "protosearch-sbt" % "0.0-d584b35-SNAPSHOT")

When the protosearch-sbt plugin is included in an sbt build, any LaikaPlugin enabled projects, will have the ProtosearchPlugin enabled as well. The ProtosearchPlugin introduces a task, protosearchGenerateIndex that will render documents using the IndexFormat introduced in https://github.com/cozydev-pink/protosearch/pull/140. Additionally this task is triggered by the laikaSite task, so index creation will happen, by default, when the site is built.

This addresses a big part of https://github.com/cozydev-pink/protosearch/issues/102, namely:

Indexing is implemented as a Laika renderer that produces an index artifact. This can be deployed as part of the site (similar to how e.g. epub / pdfs are included in the site).

The index, along with a few supporting html and js files are added to a search directory in the site output directory.

Up Next

Currently the UX of the search page is very limited, not even returning the titles of documents match! Future work in https://github.com/cozydev-pink/protosearch/issues/154 will add support for storing fields in the index which will enable us to make this search experience much better.

The plugin structure and configuration could be totally revisited. This is very much a prototype to get things working. Ultimately generating an index should probably feel a lot like generating an ePub or PDF for a Laika site, and be similarly configurable.

Lastly, the IndexFormat and TwoPhaseRenderFormat are still rather experimental and expected to change over time. It would be nice to take advantage of more structure in the Laika ASTs than just the "plaintext".

valencik commented 9 months ago

I've updated the issue title and description to better capture where this work brings us. I don't necessarily think this is the final plugin that users will end up installing to add search to their site. But it sure makes testing protosearch on real sites easy.

I'm going to merge this work as completed but leave https://github.com/cozydev-pink/protosearch/issues/102 open to track continuing efforts.