Open nhoizey opened 3 months ago
I don't know which I would classify this as — but it is something Pagefind should indeed handle better in either case, since this function is meant to offer mutation.
Internally this can pose an issue as well, ex: https://github.com/CloudCannon/pagefind/blob/fe11bee730dd15d2f35dc5cd34db8cc15e3fe592/pagefind_web_js/lib/coupled_search.ts#L286-L289
For now, I would implement a similar operation, e.g.:
processResult: function (result) {
if (!result.raw_title) {
result.raw_title = result.meta.title;
}
// Add the page type to the title
result.meta.title = `${result.filters['00. Page type']} ▸ ${result.raw_title}`;
return result;
}
Marked as a bug, with a future goal of Pagefind always providing the original unmodified values to the processResult
hook.
Thanks!
I wanted to enrich my results titles with
processResult()
, and thought this would be enough:Unfortunately, with this code, the page type (value of the
00. Page type
filter) is added in front of current title each type I check or uncheck a filter.Live demo:
Photo ▸ Inoummar agadir's Lamine
Photo ▸ Inoummar agadir's Lamine
Photo ▸ Photo ▸ Inoummar agadir's Lamine
Photo ▸ Photo ▸ Photo ▸ Inoummar agadir's Lamine
Is it a feature, and I should check/replace in my
processResult()
function, or is it a bug?