Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #678 from Shinsina/use-phrase-when-quoted
Browse files Browse the repository at this point in the history
Use `autocomplete.phrase` when configured appropriately.
  • Loading branch information
solocommand authored Apr 21, 2023
2 parents 80951ec + 866f428 commit 55a6d4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/marko-web-search/components/query.marko
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $ const {
apollo: apolloBaseCMS,
$baseBrowse: apolloBaseBrowse,
config,
site
} = out.global;
$ const { assignedToWebsiteSectionIds } = input;

Expand All @@ -21,6 +22,7 @@ $ const params = {
),
queryFragment: input.queryFragment,
opSuffix: input.opSuffix,
useAutocomplete: site.get('search.useAutocomplete', false),
};

<marko-web-resolve|{ resolved }| promise=loader({ apolloBaseCMS, apolloBaseBrowse }, params)>
Expand Down
4 changes: 3 additions & 1 deletion packages/marko-web-search/loaders/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ module.exports = async ({ apolloBaseCMS, apolloBaseBrowse } = {}, {

queryFragment,
opSuffix,
useAutocomplete = false,
} = {}) => {
if (!apolloBaseCMS || !apolloBaseBrowse) throw new Error('Both the BaseCMS and Base Browse Apollo clients must be provided.');
const input = {
omitScheduledAndExpiredContent: true,
statuses: ['PUBLISHED'],
contentTypes,
countryCodes,
...(searchQuery && { search: { query: searchQuery } }),
...(!useAutocomplete && searchQuery && { search: { query: searchQuery } }),
...(useAutocomplete && searchQuery && { autocomplete: { phrase: searchQuery } }),
...((assignedToWebsiteSiteIds.length || assignedToWebsiteSectionIds.length) && {
assignedToWebsites: {
...(assignedToWebsiteSiteIds.length && { siteIds: assignedToWebsiteSiteIds }),
Expand Down

0 comments on commit 55a6d4a

Please sign in to comment.