Skip to content

Commit

Permalink
feat: add Google site search integration for enhanced search function…
Browse files Browse the repository at this point in the history
…ality
  • Loading branch information
ccbikai committed Nov 2, 2024
1 parent c34c79f commit 7e3e611
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ NO_INDEX=false

TELEGRAM_HOST=telegram.dog
STATIC_PROXY=""
GOOGLE_SEARCH_SITE=""
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ SENTRY_PROJECT=SENTRY_PROJECT
## Telegram host name and static resource proxy, not recommended to modify
HOST=telegram.dog
STATIC_PROXY=
## Enable Google Site Search
GOOGLE_SEARCH_SITE=memo.miantiao.me
```

## 🙋🏻 FAQs
Expand Down
3 changes: 3 additions & 0 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ SENTRY_PROJECT=SENTRY_PROJECT
## Telegram 主机名称和静态资源代理,不建议修改
HOST=telegram.dog
STATIC_PROXY=
## 启用谷歌站内搜索
GOOGLE_SEARCH_SITE=memo.miantiao.me
```

## 🙋🏻 常问问题
Expand Down
6 changes: 5 additions & 1 deletion src/layouts/base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const seoParams = {
},
}
const GOOGLE_SEARCH_SITE = getEnv(import.meta.env, Astro, 'GOOGLE_SEARCH_SITE')
const searchAction = GOOGLE_SEARCH_SITE ? 'https://www.google.com/search' : '/search/result'
const HEADER_INJECT = getEnv(import.meta.env, Astro, 'HEADER_INJECT')
const FOOTER_INJECT = getEnv(import.meta.env, Astro, 'FOOTER_INJECT')
---
Expand Down Expand Up @@ -83,7 +86,8 @@ const FOOTER_INJECT = getEnv(import.meta.env, Astro, 'FOOTER_INJECT')
</div>
</div>
<input class="search-icon" name="icon" type="checkbox" placeholder="Search" />
<form class="search-form" action="/search/result" method="get">
<form class="search-form" action={searchAction} method="get">
{GOOGLE_SEARCH_SITE ? <input type="hidden" name="as_sitesearch" value={GOOGLE_SEARCH_SITE} /> : null}
<input type="text" name="q" placeholder="Search" />
</form>
<div class="copyright-wrap">
Expand Down

0 comments on commit 7e3e611

Please sign in to comment.