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";
|
import {siteConfig} from "../config";
|
||||||
const noscript = siteConfig.noClientJavaScript
|
const noscript = siteConfig.noClientJavaScript
|
||||||
|
const searchEngine = siteConfig.searchEngine || 'google'
|
||||||
|
const domain = Astro.url.host
|
||||||
---
|
---
|
||||||
{noscript ?
|
{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>
|
<div>
|
||||||
<label for="search-input"><span class="command">search</span></label>
|
<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 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>
|
</div>
|
||||||
<input type="submit" style="display: none" />
|
<input type="submit" style="display: none" />
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -7,9 +7,10 @@ export const siteConfig = {
|
||||||
noClientJavaScript: false, // disable client-side javascript, this will:
|
noClientJavaScript: false, // disable client-side javascript, this will:
|
||||||
// 1. disable all built-in client-side javascript from rendering
|
// 1. disable all built-in client-side javascript from rendering
|
||||||
// 2. the full text search will be redirected to a search engine
|
// 2. the full text search will be redirected to a search engine
|
||||||
// 3. the comments will be replaced with email reply
|
// 3. the comments will be globally disabled
|
||||||
// 4. the night mode & back to top will not use Javascript to function
|
// 4. the night mode & back to top will not use Javascript to function
|
||||||
// 5. the neko will be force-disabled
|
// 5. the neko will be force-disabled
|
||||||
|
authorDefaultEmail: '',
|
||||||
// site components
|
// site components
|
||||||
navBarItems: [
|
navBarItems: [
|
||||||
// additional items in the navbar
|
// additional items in the navbar
|
||||||
|
@ -18,6 +19,9 @@ export const siteConfig = {
|
||||||
{ text: "RSS", link: "/rss.xml" },
|
{ text: "RSS", link: "/rss.xml" },
|
||||||
{ text: "GitHub", link: "https://github.com/GrassBlock1/mercury" },
|
{ text: "GitHub", link: "https://github.com/GrassBlock1/mercury" },
|
||||||
],
|
],
|
||||||
|
// search
|
||||||
|
// This only works when noClientJavaScript is enabled
|
||||||
|
searchEngine: 'bing', // 'google', 'duckduckgo', 'bing'(broken until M1cr0$0ft get support for it), defaults to 'google'
|
||||||
// footer
|
// footer
|
||||||
// yes you can write html safely here
|
// yes you can write html safely here
|
||||||
customFooter: '<i>I have no mouth, and I must SCREAM</i>',
|
customFooter: '<i>I have no mouth, and I must SCREAM</i>',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue