-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Frontend Search with Client-side Index #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
dff3909
27638bc
7eb0166
b220eb8
58ce7ba
7d2a1be
99d8c3a
4dff898
a7cecc1
263c10e
03d9cf3
fc46a3b
67e7846
1e9b936
5bba27e
4717138
c4d913e
e55e4b5
f6f34ec
dc6a6af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,74 @@ | ||||||||||||||||||||
| import pako from 'pako' | ||||||||||||||||||||
| import { SearchResult } from '@/components/search/SearchResult' | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const REPO_INDEXES: Record<string, string> = { | ||||||||||||||||||||
| "digital.transchinese.org": "/search-index/repo-digital-transchinese-org.json.gz", | ||||||||||||||||||||
| "novel.transchinese.org": "/search-index/repo-novel-transchinese-org.json.gz", | ||||||||||||||||||||
| "comic.transchinese.org": "/search-index/repo-comic-transchinese-org.json.gz", | ||||||||||||||||||||
| "archive.cdtsf.com": "/search-index/repo-archive-cdtsf-com.json.gz", | ||||||||||||||||||||
| "news.transchinese.org": "/search-index/repo-news-transchinese-org.json.gz", | ||||||||||||||||||||
| "enovel.cdtsf.com": "/search-index/repo-enovel-cdtsf-com.json.gz", | ||||||||||||||||||||
| "fnovel.cdtsf.com": "/search-index/repo-fnovel-cdtsf-com.json.gz", | ||||||||||||||||||||
| "snovel.cdtsf.com": "/search-index/repo-snovel-cdtsf-com.json.gz", | ||||||||||||||||||||
| "unovel.transchinese.org": "/search-index/repo-unovel-transchinese-org.json.gz", | ||||||||||||||||||||
| "xnovel.transchinese.org": "/search-index/repo-xnovel-transchinese-org.json.gz", | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const cache: Record<string, any> = {} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| async function loadIndex(domain: string): Promise<any | null> { | ||||||||||||||||||||
| if (cache[domain]) return cache[domain] | ||||||||||||||||||||
| const file = REPO_INDEXES[domain] | ||||||||||||||||||||
| if (!file) return null | ||||||||||||||||||||
| try { | ||||||||||||||||||||
| const res = await fetch(file) | ||||||||||||||||||||
|
||||||||||||||||||||
| const res = await fetch(file) | |
| const res = await fetch(file) | |
| if (!res.ok) { | |
| console.error( | |
| 'Failed to fetch search index', | |
| { domain, file, status: res.status, statusText: res.statusText } | |
| ) | |
| return null | |
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| name = "transchinese-test" | ||
| compatibility_date = "2024-01-01" | ||
| account_id = "${CLOUDFLARE_ACCOUNT_ID}" | ||
|
|
||
| [site] | ||
| bucket = "./out" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| name = "transchinese-org" | ||
| compatibility_date = "2024-01-01" | ||
| account_id = "${CLOUDFLARE_ACCOUNT_ID}" | ||
|
weekendfish marked this conversation as resolved.
Outdated
|
||
|
|
||
| [site] | ||
| bucket = "./out" | ||
Uh oh!
There was an error while loading. Please reload this page.