diff --git a/src/search/pagefind.jl b/src/search/pagefind.jl index 0808bacb..cd2da1ee 100644 --- a/src/search/pagefind.jl +++ b/src/search/pagefind.jl @@ -1,5 +1,5 @@ module PageFind -using NodeJS_22_jll: npx, npm +using NodeJS_22_jll: npx, npm, node using HypertextLiteral: @htl function inject_script!(custom_scripts, rootpath) @@ -29,16 +29,22 @@ function render() end function build_search_index(root, docs, config, rootpath) - if !success(Cmd(`$(npx) pagefind -V`; dir = root)) - @info "Installing pagefind into $root." - if !success(Cmd(`$(npm) install pagefind`; dir = root)) - error("Could not install pagefind.") + # npx and npm are distributed as FileProducts, + # so the JLL does not bundle environment information into them. + # To fix this, we wrap all uses of npx and npm inside `node() do ...` + # which will automatically adjust the necessary environment variables. + node() do + if !success(Cmd(`$(npx) pagefind -V`; dir = root)) + @info "Installing pagefind into $root." + if !success(Cmd(`$(npm) install pagefind`; dir = root)) + error("Could not install pagefind.") + end end + + pattern = "*/{$(join(config.index_versions, ","))}/**/*.{html}" + + run(`$(npx) pagefind --site $(root) --glob $(pattern) --root-selector article`) end - - pattern = "*/{$(join(config.index_versions, ","))}/**/*.{html}" - - run(`$(npx) pagefind --site $(root) --glob $(pattern) --root-selector article`) return nothing end