Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 7 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.0.2
//> using dep org.webjars.npm:katex:0.16.44
//> 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-bbb1740-SNAPSHOT
//> using repository https://central.sonatype.com/repository/maven-snapshots
//> using option -deprecation

Expand Down Expand Up @@ -77,9 +77,12 @@ 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.withExcludedPaths(Path.Root / "404.md")
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.

I think this part is neat, we can define the config and settings once and then access the BinaryRendererConfig with indexConfig.config and the TwoPhaseRenderFormat for Transformers with indexConfig.format.


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

val binaryRenderers = List(
IndexRendererConfig(true),
indexConfig.config,
BinaryRendererConfig(
"rss",
LaikaCustomizations.Rss,
Expand All @@ -154,7 +157,7 @@ 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
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,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.

Because the path field no longer has the leading slash.
Which means queries like path:blog now work

const title = hit.highlights["title"] || hit.fields["title"]
const preview = hit.highlights["body"]
const tags = []
Expand Down
Loading