--- /** * Adapted from @astrojs/starlight 0.37.6 components/Search.astro. * Keep modal behavior and styles aligned with the upstream component. * * MIT License * * Copyright (c) 2023 [Astro contributors](https://github.com/withastro/starlight/graphs/contributors) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ // Preserve Starlight's search UI; apply the product filter before the first query. import { Icon } from '@astrojs/starlight/components'; import { DOCS_SEARCH_LABELS, getDocsSearchScope } from '../data/docs-search'; import project from 'virtual:starlight/project-context'; const searchScope = getDocsSearchScope(Astro.locals.starlightRoute.id); const searchLabel = `${Astro.locals.t('search.label')} ${DOCS_SEARCH_LABELS[searchScope]}`; const pagefindTranslations = { placeholder: searchLabel, search_label: searchLabel, ...Object.fromEntries( Object.entries(Astro.locals.t.all()) .filter(([key]) => key.startsWith('pagefind.')) .map(([key, value]) => [key.replace('pagefind.', ''), value]) ), }; const dataAttributes: DOMStringMap = { 'data-translations': JSON.stringify(pagefindTranslations), 'data-search-scope': searchScope, }; if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash'] = ''; ---
{ /* TODO: Make the layout of this button flexible to accommodate different word lengths. Currently hard-coded for English: “Cancel” */ } { import.meta.env.DEV ? (

{Astro.locals.t('search.devWarning')}

) : (
) }
{ /** * This is intentionally inlined to avoid briefly showing an invalid shortcut. * Purposely using the deprecated `navigator.platform` property to detect Apple devices, as the * user agent is spoofed by some browsers when opening the devtools. */ }