jameslittle230 / stork

🔎 Impossibly fast web search, made for static sites.
https://stork-search.net
Apache License 2.0
2.73k stars 56 forks source link

Add transformResultUrl callback to JS API #274

Closed ArsenArsen closed 2 years ago

ArsenArsen commented 2 years ago

Transforming result URLs allows the user to build sites that are relocatable rather anchored on the site root (for instance, by prepending the resulting URL with the relative path to the root directory).

I'm sure other uses exist too, but this is what I need it for.

Thanks

jameslittle230 commented 2 years ago

Can you give a sample code snippet of how you'd use this API?

ArsenArsen commented 2 years ago
    stork.register("stuff", rootPath + "searchidx.st", {
        "onQueryUpdate": onQueryUpdate,
        "onResultsHidden": onResultsHidden,
        "transformResultUrl": a => rootPath + a.substr(1),
    });
ArsenArsen commented 2 years ago

Ah - a release happened at almost the exact same time I did this; stellar coincidence.

I rebased on top of the new release; I think the addition of a new feature makes this 1.5.0, do correct me if I'm wrong, though.

codecov[bot] commented 2 years ago

Codecov Report

Merging #274 (43faaaa) into master (eeaca67) will increase coverage by 0.63%. The diff coverage is 81.25%.

@@            Coverage Diff             @@
##           master     #274      +/-   ##
==========================================
+ Coverage   72.44%   73.08%   +0.63%     
==========================================
  Files          53       52       -1     
  Lines        2174     2177       +3     
  Branches      104      104              
==========================================
+ Hits         1575     1591      +16     
+ Misses        598      585      -13     
  Partials        1        1              
Impacted Files Coverage Δ
stork-cli/src/clap.rs 100.00% <ø> (ø)
stork-cli/src/main.rs 0.00% <0.00%> (ø)
stork-lib/src/index_v3/build/fill_stems.rs 100.00% <ø> (ø)
stork-lib/src/index_v3/mod.rs 70.37% <ø> (ø)
stork-lib/src/index_v3/build/errors.rs 80.95% <50.00%> (+0.46%) :arrow_up:
...rc/index_v3/build/fill_intermediate_entries/mod.rs 90.99% <75.00%> (+0.99%) :arrow_up:
stork-lib/src/index_v3/build/mod.rs 96.42% <89.47%> (-2.15%) :arrow_down:
js/config.ts 82.35% <100.00%> (+1.10%) :arrow_up:
js/entity.ts 65.45% <100.00%> (ø)
stork-lib/src/index_v3/build/fill_containers.rs 91.80% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2df0e4b...43faaaa. Read the comment docs.