Skip to content

feat($theme): Add search box placeholder setting to theme-config #1834

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

Merged
merged 1 commit into from
Sep 10, 2019
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
7 changes: 6 additions & 1 deletion packages/@vuepress/plugin-search/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
aria-label="Search"
:value="query"
:class="{ 'focused': focused }"
:placeholder="placeholder"
autocomplete="off"
spellcheck="false"
@focus="focused = true"
Expand Down Expand Up @@ -42,10 +43,14 @@ export default {
return {
query: '',
focused: false,
focusIndex: 0
focusIndex: 0,
placeholder: undefined
}
},

mounted () {
this.placeholder = this.$site.themeConfig.searchPlaceholder || ''
},
computed: {
showSuggestions () {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<input
id="algolia-search-input"
class="search-query"
:placeholder="placeholder"
>
</form>
</template>
Expand All @@ -15,8 +16,15 @@
export default {
props: ['options'],

data () {
return {
placeholder: undefined
}
},

mounted () {
this.initialize(this.options, this.$lang)
this.placeholder = this.$site.themeConfig.searchPlaceholder || ''
},

methods: {
Expand Down
12 changes: 12 additions & 0 deletions packages/docs/docs/theme/default-theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,18 @@ Unlike the [built-in search](#built-in-search) engine which works out of the box

For more options, check out [Algolia DocSearch’s documentation](https://github.com/algolia/docsearch#docsearch-options).

### Search Placeholder

You can define a placeholder for the search box by adding the `searchPlaceholder` attribute:

``` js
module.exports = {
themeConfig: {
searchPlaceholder: 'Search...'
}
}
```

## Last Updated

The `themeConfig.lastUpdated` option allows you to get the UNIX timestamp(ms) of each file’s last `git` commit, and it will also display at the bottom of each page in an appropriate format:
Expand Down