From 247351ce2b2a3614af21e56bb28194811b167132 Mon Sep 17 00:00:00 2001 From: Michel Edighoffer Date: Mon, 17 Oct 2022 01:22:35 +0200 Subject: [PATCH 1/4] feat: add algolia translations types --- src/vitepress/config.ts | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/vitepress/config.ts b/src/vitepress/config.ts index eedfc30..97ae52b 100644 --- a/src/vitepress/config.ts +++ b/src/vitepress/config.ts @@ -87,6 +87,55 @@ export interface AlgoliaSearchOptions { searchParameters?: any disableUserPersonalization?: boolean initialQuery?: string + translations?: Partial +} + +export interface DocSearchTranslations { + button?: ButtonTranslations + modal?: ModalTranslations +} + +export interface ButtonTranslations { + buttonText?: string + buttonAriaLabel?: string +} +export interface ModalTranslations extends ScreenStateTranslations { + searchBox?: { + resetButtonTitle?: string + resetButtonAriaLabel?: string + cancelButtonText?: string + cancelButtonAriaLabel?: string + } + footer?: { + selectText?: string + selectKeyAriaLabel?: string + navigateText?: string + navigateUpKeyAriaLabel?: string + navigateDownKeyAriaLabel?: string + closeText?: string + closeKeyAriaLabel?: string + searchByText?: string + } +} +export interface ScreenStateTranslations { + errorScreen?: { + titleText?: string + helpText?: string + } + startScreen?: { + recentSearchesTitle?: string + noRecentSearchesText?: string + saveRecentSearchButtonTitle?: string + removeRecentSearchButtonTitle?: string + favoriteSearchesTitle?: string + removeFavoriteSearchButtonTitle?: string + } + noResultsScreen?: { + noResultsText?: string + suggestedQueryText?: string + reportMissingResultsText?: string + reportMissingResultsLinkText?: string + } } export type NavItem = NavItemWithLink | NavItemWithChildren From db14d0431e9c643cfae0665516e88be030219dfb Mon Sep 17 00:00:00 2001 From: Michel Edighoffer Date: Mon, 17 Oct 2022 01:46:32 +0200 Subject: [PATCH 2/4] fix: use raw data to avoid proxy issue + update demo --- demo/.vitepress/config.js | 20 +++++++++++++++++-- .../components/VPAlgoliaSearchBox.vue | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/demo/.vitepress/config.js b/demo/.vitepress/config.js index 835b391..1abddc2 100644 --- a/demo/.vitepress/config.js +++ b/demo/.vitepress/config.js @@ -2,10 +2,11 @@ const getBase = require('../../src/vitepress/config/baseConfig') const path = require('path') /** - * @type {() => Promise} + * @type {() => Promise { const base = await getBase() + return { ...base, @@ -25,13 +26,28 @@ module.exports = (async () => { title: 'Vue.js', description: 'Vue.js - The Progressive JavaScript Framework', + /** + * @type {import('../../src/vitepress/config').Config} + */ themeConfig: { logo: '/img/logo-vue.svg', algolia: { indexName: 'vuejs-v3', appId: 'BH4D9OD16A', - apiKey: 'bc6e8acb44ed4179c30d0a45d6140d3f' + apiKey: 'bc6e8acb44ed4179c30d0a45d6140d3f', + placeholder: 'Search on Vue theme', + translations: { + modal: { + searchBox: { + cancelButtonText: 'Abort', + resetButtonTitle: 'Clear search term' + }, + footer: { + searchByText: 'Search gracefully done by ' + } + } + } }, carbonAds: { diff --git a/src/vitepress/components/VPAlgoliaSearchBox.vue b/src/vitepress/components/VPAlgoliaSearchBox.vue index cc92aae..76439c8 100644 --- a/src/vitepress/components/VPAlgoliaSearchBox.vue +++ b/src/vitepress/components/VPAlgoliaSearchBox.vue @@ -1,7 +1,7 @@