From a512cd39af346d69418d24cb01edf6d6193567d4 Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Tue, 12 Jul 2022 11:42:57 +0200 Subject: [PATCH 1/3] Update docs-searchbar.js to v2.2.0 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index b4b3a31..2470b97 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "main": "index.js", "dependencies": { - "docs-searchbar.js": "^2.1.1" + "docs-searchbar.js": "^2.2.0" }, "resolutions": { "yargs-parser": "^13.1.2" diff --git a/yarn.lock b/yarn.lock index 59e0c1f..47cee84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3760,13 +3760,13 @@ dns-txt@^2.0.2: dependencies: buffer-indexof "^1.0.0" -docs-searchbar.js@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/docs-searchbar.js/-/docs-searchbar.js-2.1.1.tgz#ed9519c0f39a99ad9d231963245e4fc81edd994b" - integrity sha512-K9QkhpLUi8KRoEoI8Gz7dOAYHSPUZ0uB3qb0QkWsq9cU+FAMCZPQoePfN9TObTKcX95AYQUXHV2cgd1StHYWrg== +docs-searchbar.js@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/docs-searchbar.js/-/docs-searchbar.js-2.2.0.tgz#e60eb0ee4f67853c41fdf7d3a4ef6ac7ac2c8027" + integrity sha512-rleKMiTkxG14M+6yt3+H8H0w/GKxWsNMinf4+zTVz9aVi04oJ8u37kktTiW3qkpPl9VQ7/i7Yv9wykukMqVxfw== dependencies: autocomplete.js "^0.38.1" - meilisearch "^0.25.0" + meilisearch "^0.27.0" to-factory "^1.0.0" zepto "^1.2.0" @@ -6673,10 +6673,10 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -meilisearch@^0.25.0: - version "0.25.0" - resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.25.0.tgz#8e980fbdd36b9fe6ed606205e262418f21e64d84" - integrity sha512-TSIJTh5lva7WHBaoG3arNYQXuIAQkcD3BY09h2nHhjHS/wzxWKJM45x5bEC67Grw8zXihVqqmWty4a4ps4S+tg== +meilisearch@^0.27.0: + version "0.27.0" + resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.27.0.tgz#8bd57ddb77b975f93e054cb977b951c488ece297" + integrity sha512-kZOZFIuSO7c6xRf+Y2/9/h6A9pl0sCl/G44X4KuaSwxGbruOZPhmxbeVEgLHBv4pUFvQ56rNVTA/2d/5GCU1YA== dependencies: cross-fetch "^3.1.5" From 137710f899bbf7c1a3c681d0b3b21bbbf743865a Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Tue, 12 Jul 2022 12:32:57 +0200 Subject: [PATCH 2/3] Pass Vuepress client agent to meilisearch-js --- MeiliSearchBox.vue | 1 + client_agents.js | 11 +++++++++++ index.js | 5 ++++- playground/package.json | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 client_agents.js diff --git a/MeiliSearchBox.vue b/MeiliSearchBox.vue index 183ef03..48df0ab 100644 --- a/MeiliSearchBox.vue +++ b/MeiliSearchBox.vue @@ -30,6 +30,7 @@ export default { hostUrl: HOST_URL, apiKey: API_KEY, indexUid: INDEX_UID, + clientAgents: CLIENT_AGENTS, meilisearchOptions: { limit: MAX_SUGGESTIONS || this.$site.themeConfig.searchMaxSuggestions || 5, diff --git a/client_agents.js b/client_agents.js new file mode 100644 index 0000000..fc221bc --- /dev/null +++ b/client_agents.js @@ -0,0 +1,11 @@ +const { version } = require('./package.json') + +const constructClientAgents = (clientAgents = []) => { + const vuepressAgents = `Meilisearch Vuepress (v${version})` + + return clientAgents.concat(vuepressAgents) +} + +module.exports = { + constructClientAgents +} diff --git a/index.js b/index.js index 9aa8607..8fb9644 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ const path = require('path') +const { constructClientAgents } = require('./client_agents') + module.exports = (options) => { return { alias: { @@ -15,7 +17,8 @@ module.exports = (options) => { CROP_LENGTH: options.cropLength || 30, LAYOUT: options.layout || 'columns', DEBUG: options.debug || false, - ENABLE_DARK_MODE: options.enableDarkMode || false + ENABLE_DARK_MODE: options.enableDarkMode || false, + CLIENT_AGENTS: constructClientAgents(options.clientAgents) } } } diff --git a/playground/package.json b/playground/package.json index 8d209cb..f15a54b 100644 --- a/playground/package.json +++ b/playground/package.json @@ -9,7 +9,7 @@ "setup": "node setup.js" }, "dependencies": { - "meilisearch": "^0.25.0", + "meilisearch": "^0.27.0", "vuepress": "^1.4.1", "vuepress-theme-default-prefers-color-scheme": "^2.0.0" } From e16007c3a1ed1573683f401258048adbcc272cd7 Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Tue, 12 Jul 2022 13:51:02 +0200 Subject: [PATCH 3/3] Add client agents as global in jest tests --- .eslintrc.js | 3 ++- index.js | 2 +- jest.config.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index eeb4793..f09d92c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,7 +16,8 @@ module.exports = { PLACEHOLDER: 'readonly', LAYOUT: 'readonly', DEBUG: 'readonly', - ENABLE_DARK_MODE: 'readonly' + ENABLE_DARK_MODE: 'readonly', + CLIENT_AGENTS: 'readonly' }, parserOptions: { parser: 'babel-eslint', diff --git a/index.js b/index.js index 8fb9644..ccf99a4 100644 --- a/index.js +++ b/index.js @@ -18,7 +18,7 @@ module.exports = (options) => { LAYOUT: options.layout || 'columns', DEBUG: options.debug || false, ENABLE_DARK_MODE: options.enableDarkMode || false, - CLIENT_AGENTS: constructClientAgents(options.clientAgents) + CLIENT_AGENTS: constructClientAgents(options.clientAgents) || [] } } } diff --git a/jest.config.js b/jest.config.js index 9e5ae70..49b4167 100644 --- a/jest.config.js +++ b/jest.config.js @@ -16,6 +16,7 @@ module.exports = { CROP_LENGTH: 30, LAYOUT: 'columns', DEBUG: false, - ENABLE_DARK_MODE: false + ENABLE_DARK_MODE: false, + CLIENT_AGENTS: [] } }