Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: customizable search placeholder #1126

Merged
merged 2 commits into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/guides-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ const siteConfig = {
};
```

## Customizing the placeholder

If you want to change the placeholder (which defaults to *Search*), add the `placeholder` field in your config. For example, you may want the search bar to display *Ask me something*:

```js
const siteConfig = {
...
algolia: {
...
placeholder: 'Ask me something'
},
};
```

## Disabling the Search Bar

To disable the search bar, comment out (recommended) or delete the `algolia` section in the `siteConfig.js` file.
Expand Down
5 changes: 3 additions & 2 deletions v1/lib/core/nav/HeaderNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ class HeaderNav extends React.Component {
let docGroupActive = false;
if (link.search && this.props.config.algolia) {
// return algolia search bar
const placeholder = this.props.config.algolia.placeholder || 'Search';
return (
<li className="navSearchWrapper reactNavSearchWrapper" key="search">
<input
id="search_input_react"
type="text"
placeholder="Search"
title="Search"
placeholder={placeholder}
title={placeholder}
/>
</li>
);
Expand Down