cozydev-pink / protosearch

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

Bundle search UI as a theme extension #194

Closed jenshalm closed 6 months ago

jenshalm commented 6 months ago

This PR duplicates the resources from the sbt plugin into the laikaIO module and bundles them as a theme provider. Note that the plugin references 4 files, but I could only see 3.

A plugin user can then simply apply both the UI and the index renderer with standard Laika settings (once 1.1 is out):

laikaTheme := Helium.defaults.extendWith(SearchUI).build

laikaRenderers += BinaryRendererConfig(
  alias = "index",
  format = IndexFormat,
  artifact = Artifact(
    basePath = Root / "search" / "searchIndex",
    suffix = "idx"
  ),
  includeInSite = someCustomSetting.value,
  supportsSeparations = false
)

If you'd keep the plugin, that's all that would be inside, which is why it's probably not necessary to keep publishing it.

An API user can then as easily use IndexFormat and SearchUI:

val indexRenderer = Renderer
  .of(IndexFormat)
  .parallel[IO]
  .build

val htmlRenderer = Renderer
  .of(HTML)
  .parallel[IO]
  .withTheme(Helium.defaults.extendWith(SearchUI).build)
  .build