{"id":16005546,"url":"https://github.com/kwaa/workers-hexo-search","last_synced_at":"2025-08-01T10:38:35.624Z","repository":{"id":115151349,"uuid":"329748539","full_name":"kwaa/workers-hexo-search","owner":"kwaa","description":"Multi-site Hexo search script built with Cloudflare Workers.","archived":false,"fork":false,"pushed_at":"2021-01-15T21:03:24.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T10:21:18.599Z","etag":null,"topics":["cloudflare-workers","hexo"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kwaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-14T22:22:30.000Z","updated_at":"2021-01-15T21:03:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"dbce9e0e-dd08-46f8-b7f9-99e35e09a2af","html_url":"https://github.com/kwaa/workers-hexo-search","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwaa%2Fworkers-hexo-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwaa%2Fworkers-hexo-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwaa%2Fworkers-hexo-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwaa%2Fworkers-hexo-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kwaa","download_url":"https://codeload.github.com/kwaa/workers-hexo-search/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276188,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-workers","hexo"],"created_at":"2024-10-08T11:05:14.062Z","updated_at":"2025-04-05T02:13:46.615Z","avatar_url":"https://github.com/kwaa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# workers-hexo-search\n\nMulti-site Hexo search script built with Cloudflare Workers.\n\n使用 Cloudflare Workers 构建的多站点 Hexo 搜索脚本。\n\n## Deploy / 部署\n\n- A: Copy the [index.js](https://github.com/kwaa/workers-hexo-search/blob/master/index.js) in this repository to the Cloudflare Workers quick editor, and click \"Save and Deploy\"\n\n    复制本仓库中的 [index.js](https://github.com/kwaa/workers-hexo-search/blob/master/index.js) 到 Cloudflare Workers 快速编辑器，然后点击 \"保存并部署\"\n\n- B: Use the \"Deploy with Workers\" button below\n\n    使用下面的 \"Deploy with Workers\" 按钮\n\n[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/kwaa/workers-hexo-search)\n\n## Configuration / 配置\n\nConfigure the site and error messages in ```index.js```:\n\n在 ```index.js``` 中配置站点和错误信息：\n\n```javascript\nconst [site, error] = [{\n    \"example.com\": \"https://example.com/search.json\",\n    \"https://example.com\": \"https://example.com/search.json\",\n    }, `usage:\\n\\\n    ?siteSearch=\u003csite\u003e\u0026q=\u003ckeyword\u003e\\n\\\n    required: q`]\n```\n\nOnly the ```search.json``` file generated with [hexo-search-generator](https://github.com/wzpan/hexo-generator-search) is supported, not support XML format.\n\n仅支持通过 [hexo-search-generator](https://github.com/wzpan/hexo-generator-search) 生成的 ```search.json``` 文件，不支持 XML 格式。\n\n(If you deploy via button) Edit ```wrangler.toml``` to rename the Worker name:\n\n（如果你通过按钮部署）编辑 ```wrangler.toml``` 以重命名 Worker 名称：\n\n```toml\nname = \"hexo-search\"\n```\n\n## Example / 用例\n\nThere are two ways to use as a reference:\n\n有两种使用方式作为参考：\n\n\u003e Press ENTER to search / 回车搜索\n\n```html\n\u003cform onsubmit=\"return search(this.searchTerm.value)\"\u003e\n  \u003cinput type=\"text\" id=\"searchTerm\" name=\"q\"\u003e\n\u003c/form\u003e\n\u003cdiv id=\"result\"\u003e\u003c/div\u003e\n\u003cscript\u003e\n  function search(searchTerm) {\n    fetch(`https://${workers}/?siteSearch=${site}\u0026q=${searchTerm}`)\n      .then(res =\u003e res.json().then(json =\u003e json.items.forEach(({title, link, snippet}) =\u003e\n        document.getElementById('result').insertAdjacentHTML('beforeend', `\n          \u003cdiv\u003e\n            \u003ca href=\"${link}\"\u003e${title}\u003c/a\u003e\n            \u003cspan\u003e${snippet}\u003c/span\u003e\n          \u003c/div\u003e\n        `)\n      )));\n    return false;\n  }\n\u003c/script\u003e\n```\n\n\u003e Instant search / 即时搜索\n\n```html\n\u003cform onkeydown=\"if (event.keyCode == 13) return false\"\u003e\n  \u003cinput type=\"text\" id=\"searchTerm\" name=\"q\"\u003e\n\u003c/form\u003e\n\u003cdiv id=\"result\"\u003e\u003c/div\u003e\n\u003cscript\u003e\n  document.getElementById('searchTerm').addEventListener('input', () =\u003e {\n    document.getElementById('result').innerHTML = ''\n    let searchTerm = document.getElementById('searchTerm').value.trim().toLowerCase();\n    if (searchTerm.length \u003e 0) fetch(`https://${workers}/?siteSearch=${site}\u0026q=${searchTerm}`)\n      .then(res =\u003e res.json().then(json =\u003e json.items.forEach(({ title, link, snippet }) =\u003e\n        document.getElementById('result').insertAdjacentHTML('beforeend', `\n          \u003cdiv\u003e\n            \u003ca href=\"${link}\"\u003e${title}\u003c/a\u003e\n            \u003cspan\u003e${snippet}\u003c/span\u003e\n          \u003c/div\u003e\n        `)\n      )));\n  })\n\u003c/script\u003e\n```\n\n## License / 许可证\n\nThis work is distributed under the WTFPL licence. See the [COPYING](https://github.com/kwaa/workers-hexo-search/blob/master/COPYING) file for more details.\n\n此项目是根据 WTFPL 许可证分发的。有关更多详细信息，请参见 [COPYING](https://github.com/kwaa/workers-hexo-search/blob/master/COPYING) 文件。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwaa%2Fworkers-hexo-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkwaa%2Fworkers-hexo-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwaa%2Fworkers-hexo-search/lists"}