Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
feat(docsearch): attach docsearch.js user agent to vanilla renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Jul 9, 2020
1 parent edf6b9b commit e1bd8d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/docsearch-js/src/docsearch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { render } from 'preact/compat';

import { DocSearch } from '@docsearch/react';
import { DocSearch, version } from '@docsearch/react';

function getHTMLElement(
value: string | HTMLElement,
Expand All @@ -15,7 +15,16 @@ function getHTMLElement(

export function docsearch(props) {
render(
<DocSearch {...props} />,
<DocSearch
{...props}
transformSearchClient={(searchClient) => {
searchClient.addAlgoliaAgent(`docsearch.js (${version})`);

return props.transformSearchClient
? props.transformSearchClient(searchClient)
: searchClient;
}}
/>,
getHTMLElement(props.container, props.environment)
);
}
1 change: 1 addition & 0 deletions packages/docsearch-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './DocSearch';
export * from './DocSearchButton';
export * from './DocSearchModal';
export * from './useDocSearchKeyboardEvents';
export * from './version';

0 comments on commit e1bd8d3

Please sign in to comment.