--- import type { Props } from '@astrojs/starlight/props'; import '@docsearch/css/dist/modal.css'; import type docsearch from '@docsearch/js'; import './variables.css'; const { labels } = Astro.props; type DocSearchTranslationProps = Pick< Parameters[0], 'placeholder' | 'translations' >; const pick = (keyStart: string) => Object.fromEntries( Object.entries(labels) .filter(([key]) => key.startsWith(keyStart)) .map(([key, value]) => [key.replace(keyStart, ''), value]) ); const docsearchTranslations: DocSearchTranslationProps = { placeholder: labels['search.label'], translations: { button: { buttonText: labels['search.label'], buttonAriaLabel: labels['search.label'] }, modal: { searchBox: pick('docsearch.searchBox.'), startScreen: pick('docsearch.startScreen.'), errorScreen: pick('docsearch.errorScreen.'), footer: pick('docsearch.footer.'), noResultsScreen: pick('docsearch.noResultsScreen.'), }, }, }; ---