Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//> using dep org.graalvm.js:js:25.1.3
//> using dep org.webjars.npm:katex:0.17.0
//> using dep org.webjars.npm:fortawesome__fontawesome-free:7.2.0
//> using dep pink.cozydev::protosearch-laika:0.0-7f79720-SNAPSHOT
//> using dep pink.cozydev::protosearch-laika:0.0-0aa7335-SNAPSHOT
//> using repository https://central.sonatype.com/repository/maven-snapshots
//> using option -deprecation

Expand Down Expand Up @@ -77,9 +77,11 @@ object LaikaBuild {
import laika.io.syntax.*
import laika.parse.code.languages.ScalaSyntax
import laika.theme.*
import pink.cozydev.protosearch.analysis.{IndexFormat, IndexRendererConfig}
import pink.cozydev.protosearch.laika.IndexConfig
import pink.cozydev.protosearch.ui.SearchUI

val indexConfig = IndexConfig.default

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is that we configure the protosearch-laika IndexConfig once and can then reuse it to get the Laika BinaryRendererConfig or IndexFormat depending on which we need.
Currently we're just using the default config, in the future we might configure other settings like which HOCON keys to add to the index as data.


def input = {
val securityPolicy = new URI(
"https://raw.githubusercontent.com/typelevel/.github/refs/heads/main/SECURITY.md"
Expand Down Expand Up @@ -128,7 +130,7 @@ object LaikaBuild {
.build

val binaryRenderers = List(
IndexRendererConfig(true),
indexConfig.config,
BinaryRendererConfig(
"rss",
LaikaCustomizations.Rss,
Expand All @@ -154,7 +156,11 @@ object LaikaBuild {
.parallel[IO]
.build
val index =
Renderer.of(IndexFormat).withConfig(parser.config).parallel[IO].build
Renderer
.of(indexConfig.format)
.withConfig(parser.config)
.parallel[IO]
.build

(html, rss, index).tupled.use { (html, rss, index) =>
parser.fromInput(input).parse.flatMap { tree =>
Expand Down
7 changes: 5 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function hideSearchModal() {
}

function renderHit(hit) {
const link = `${hit.fields.path}.html`
const link = `/${hit.fields.path}.html`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indexed path field now omits the top level slash.

const title = hit.highlights["title"] || hit.fields["title"]
const preview = hit.highlights["body"]
const tags = []
Expand Down Expand Up @@ -62,7 +62,10 @@ searchWorker.onmessage = function (e) {
}

function onSearchInput(event) {
searchWorker.postMessage({"query": event.target.value || ""});
searchWorker.postMessage({
"query": event.target.value || "",
"size": 50
});
}

// Keyboard shortcuts: `/` to open, `Escape` to close
Expand Down
Loading