-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
combinedAnswers.attributesToDisplay?.filter is not a function #6023
Comments
attributesToDisplay is meant to be an array of strings, I wonder if what you're looking for is a separate data-bag to store these more "static" information. Would that help your use case? Something along the lines of: {
// ... other configuration
"attributesToDisplay": [],
"data": {
"hit": {
"title": {
"href": "url",
"text": "hierarchy.lvl2",
"highlight": true
},
"subtitle": {
"text": "hierarchy.lvl1"
}
}
}
} If you're interested in that, we'd be happy to see a PR adding a new |
Thanks for the response @Haroenv. Well the benefit of being able to use a dictionary rather than an array is extending its usability which also eliminates the need for a loop when it comes to using them in the template. Unless there is an easier way to know whether {{#if attributesToDisplay.title}}
{{#if attributesToDisplay.title.href}}
<a class="text-decoration-none" href="\{{attributesToDisplay.title.href}}">{{attributesToDisplay.title}}</a>
{{/if}}
{{/if}} The attributesForFaceting seems to tolerate non-array structures: {
attributesForFaceting:
Array.isArray(combinedAnswers.attributesForFaceting) &&
combinedAnswers.attributesForFaceting.filter(
(attribute) => attribute !== 'ais.dynamicWidgets'
),
} |
I see your use case, but |
This makes it consistent with `attributesForFaceting`. See #6023 for more info, although it doesn't change that use case.
@Haroenv Perfect! Since I'm using it in a custom template, I can live with that for now. Thank you :) |
This makes it consistent with `attributesForFaceting`. See #6023 for more info, although it doesn't change that use case.
馃悰 Current behavior
In a custom template, we used to be able to send in a dictionary as the
attributesToDisplay
in order to provide some additional attributes for the template engine to display. The referenced line breaks that possibility.instantsearch/packages/create-instantsearch-app/src/cli/postProcessAnswers.js
Line 68 in c841133
Here's en example of how our config looks like:
馃攳 Steps to reproduce
attributesToDisplay
parameter.create-instantsearch-app
.Live reproduction
https://codesandbox.io/p/devbox/lh2cmc
馃挱 Expected behavior
Run
./create
in a terminal and witness the error.Package version
4.64.2
Operating system
macOS 14.2.1
Browser
Firefox 122.0
Code of Conduct
The text was updated successfully, but these errors were encountered: