diff --git a/build.scala b/build.scala index 9c7eac4d..fae0e899 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,13 @@ 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 indexExclusions = Path.Root / "404.md" +: Redirects.paths + val indexConfig = + IndexConfig.withExcludedPaths(indexExclusions*) + def input = { val securityPolicy = new URI( "https://raw.githubusercontent.com/typelevel/.github/refs/heads/main/SECURITY.md" @@ -128,7 +132,7 @@ object LaikaBuild { .build val binaryRenderers = List( - IndexRendererConfig(true), + indexConfig.config, BinaryRendererConfig( "rss", LaikaCustomizations.Rss, @@ -154,7 +158,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 => @@ -484,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" %}""" 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 = []