Skip to content

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 c7f2645 commit f9398c4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions 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)
);
}

0 comments on commit f9398c4

Please sign in to comment.