Repository navigation
fix(build): write the search index in path order - #807
Merged
Merged
Conversation
`cook build web` listed the search index in the order of a walk over the recipe tree, whose children are a `HashMap`: the order changed from one run to the next, so an unchanged collection wrote a different `static/search-index.js` every time, and a site published through git or rsync always had a change to ship. It was the only file that differed; the sitemap already sorts by path for this reason. The index is now sorted by path. Search ranks by score with a stable sort, so equal scores now also list in path order. Introduced with the static-site generator in f6703df (cooklang#344). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmrM91dHzvQoaerCcR9wra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #806
build_search_indexnow sorts its entries by path, as the sitemap already does, so an unchanged collection always writes the samestatic/search-index.js.The static search ranks results by score with a stable sort (
static/js/search.js), so results with equal scores now also come out in path order instead of a random one. Nothing else about search changes.Tests
tests/build_reproducible_test.rsbuilds the seed twice with--sitemapand--feedon (with isolated config) and requires every written file to be byte-identical. It failed 3 runs out of 3 without the sort, namingstatic/search-index.js, and passes with it.cargo clippy --all-targetsis clean;cargo test --workspace: 1873 passed.static-file-search.spec.tslocally (it needs atarget/debug/cookthat runs inside the Playwright container); CI runs it.🤖 Generated with Claude Code
https://claude.ai/code/session_01MmrM91dHzvQoaerCcR9wra