From 55b1b2d4bb99c78cc08cf0c493de3b250b9787cb Mon Sep 17 00:00:00 2001 From: Andrew Valencik Date: Wed, 15 Apr 2026 20:38:52 -0400 Subject: [PATCH 1/3] Update protosearch, exclude the 404 page --- build.scala | 11 +++++++---- src/main.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build.scala b/build.scala index 9c7eac4d..dbe728a6 100644 --- a/build.scala +++ b/build.scala @@ -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 @@ -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") + def input = { val securityPolicy = new URI( "https://raw.githubusercontent.com/typelevel/.github/refs/heads/main/SECURITY.md" @@ -128,7 +131,7 @@ object LaikaBuild { .build val binaryRenderers = List( - IndexRendererConfig(true), + indexConfig.config, BinaryRendererConfig( "rss", LaikaCustomizations.Rss, @@ -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 => diff --git a/src/main.js b/src/main.js index 2affcbf9..c3fd0495 100644 --- a/src/main.js +++ b/src/main.js @@ -26,7 +26,7 @@ function hideSearchModal() { } function renderHit(hit) { - const link = `${hit.fields.path}.html` + const link = `/${hit.fields.path}.html` const title = hit.highlights["title"] || hit.fields["title"] const preview = hit.highlights["body"] const tags = [] From 8e84b0798afb14b32f9029c2f6623538545d46aa Mon Sep 17 00:00:00 2001 From: Andrew Valencik Date: Wed, 15 Apr 2026 20:47:24 -0400 Subject: [PATCH 2/3] Fix formatting --- build.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.scala b/build.scala index dbe728a6..837b0a71 100644 --- a/build.scala +++ b/build.scala @@ -157,7 +157,11 @@ object LaikaBuild { .parallel[IO] .build val index = - Renderer.of(indexConfig.format).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 => From 0990babd7909447ee8975516aa7948023ba7c125 Mon Sep 17 00:00:00 2001 From: Andrew Valencik Date: Wed, 15 Apr 2026 21:22:18 -0400 Subject: [PATCH 3/3] Exclude empty redirect docs from index --- build.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.scala b/build.scala index 837b0a71..fae0e899 100644 --- a/build.scala +++ b/build.scala @@ -80,8 +80,9 @@ object LaikaBuild { import pink.cozydev.protosearch.laika.IndexConfig import pink.cozydev.protosearch.ui.SearchUI + val indexExclusions = Path.Root / "404.md" +: Redirects.paths val indexConfig = - IndexConfig.withExcludedPaths(Path.Root / "404.md") + IndexConfig.withExcludedPaths(indexExclusions*) def input = { val securityPolicy = new URI( @@ -491,6 +492,8 @@ object Redirects { tree.addString(mkRedirect(to), Root / (from.stripSuffix(".html") + ".md")) } + def paths = map.keys.map(p => Root / p.stripSuffix(".html")).toList + private def mkRedirect(to: String) = s"""{% laika.html.template = "/templates/redirect.template.html", laika.targetFormats: [html], target = "$to" %}"""