Skip to content

Commit c9b79ef

Browse files
authored
Pass client agents to meilisearch (#244)
* Update docs-searchbar.js to v2.2.0 * Pass Vuepress client agent to meilisearch-js * Add client agents as global in jest tests
1 parent ca8763d commit c9b79ef

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module.exports = {
1616
PLACEHOLDER: 'readonly',
1717
LAYOUT: 'readonly',
1818
DEBUG: 'readonly',
19-
ENABLE_DARK_MODE: 'readonly'
19+
ENABLE_DARK_MODE: 'readonly',
20+
CLIENT_AGENTS: 'readonly'
2021
},
2122
parserOptions: {
2223
parser: 'babel-eslint',

MeiliSearchBox.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default {
3030
hostUrl: HOST_URL,
3131
apiKey: API_KEY,
3232
indexUid: INDEX_UID,
33+
clientAgents: CLIENT_AGENTS,
3334
meilisearchOptions: {
3435
limit:
3536
MAX_SUGGESTIONS || this.$site.themeConfig.searchMaxSuggestions || 5,

client_agents.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { version } = require('./package.json')
2+
3+
const constructClientAgents = (clientAgents = []) => {
4+
const vuepressAgents = `Meilisearch Vuepress (v${version})`
5+
6+
return clientAgents.concat(vuepressAgents)
7+
}
8+
9+
module.exports = {
10+
constructClientAgents
11+
}

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const path = require('path')
22

3+
const { constructClientAgents } = require('./client_agents')
4+
35
module.exports = (options) => {
46
return {
57
alias: {
@@ -15,7 +17,8 @@ module.exports = (options) => {
1517
CROP_LENGTH: options.cropLength || 30,
1618
LAYOUT: options.layout || 'columns',
1719
DEBUG: options.debug || false,
18-
ENABLE_DARK_MODE: options.enableDarkMode || false
20+
ENABLE_DARK_MODE: options.enableDarkMode || false,
21+
CLIENT_AGENTS: constructClientAgents(options.clientAgents) || []
1922
}
2023
}
2124
}

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
CROP_LENGTH: 30,
1717
LAYOUT: 'columns',
1818
DEBUG: false,
19-
ENABLE_DARK_MODE: false
19+
ENABLE_DARK_MODE: false,
20+
CLIENT_AGENTS: []
2021
}
2122
}

0 commit comments

Comments
 (0)