feat: search engine config for search bar without javascript
This commit is contained in:
parent
b695fe9fd5
commit
e605e4ed42
2 changed files with 20 additions and 3 deletions
|
@ -1,13 +1,26 @@
|
|||
---
|
||||
import {siteConfig} from "../config";
|
||||
const noscript = siteConfig.noClientJavaScript
|
||||
const searchEngine = siteConfig.searchEngine || 'google'
|
||||
const domain = Astro.url.host
|
||||
---
|
||||
{noscript ?
|
||||
<form class="search-container" action="https://www.google.com/search" method="GET" target="_blank">
|
||||
<form class="search-container" action={searchEngine === "duckduckgo" ? "https://duckduckgo.com/" :
|
||||
searchEngine === "bing" ? "https://www.bing.com/search" :
|
||||
"https://www.google.com/search"} method="GET" target="_blank">
|
||||
<div>
|
||||
<label for="search-input"><span class="command">search</span></label>
|
||||
<input name="q" type="text" id="search-input" class="search-input" autocomplete="off" placeholder="Type to search..." />
|
||||
<input type="hidden" name="as_sitesearch" value={Astro.url.host} />
|
||||
{searchEngine === "duckduckgo" &&
|
||||
<input type="hidden" name="sites" value={domain} />
|
||||
}
|
||||
{searchEngine === "google" &&
|
||||
<input type="hidden" name="as_sitesearch" value={domain} />
|
||||
}
|
||||
{/* broken until M1cr0$0ft get support for it */}
|
||||
{searchEngine === "bing" &&
|
||||
<input type="hidden" name="site" value={domain} />
|
||||
}
|
||||
</div>
|
||||
<input type="submit" style="display: none" />
|
||||
</form>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue