Open bglw opened 7 months ago
Workaround from discussion:
new PagefindUI({
element: "#search",
showSubResults: true,
showImages: true,
processResult: function (result) {
if (result?.meta?.image) {
let resultBase = new URL(result.url, window.location);
let remappedImage = new URL(result.meta.image, resultBase);
if (remappedImage.hostname !== window.location.hostname) {
result.meta.image = remappedImage.toString();
} else {
result.meta.image = remappedImage.pathname;
}
}
}
});
This can pretty much be rolled into the Default (and Modular) UI handling verbatim. I'm wary of adding it any earlier in the flow, as someone might be relying on the indexing and JS API to not mutate metadata.
Discussed in https://github.com/CloudCannon/pagefind/discussions/529