{"id":17025874,"url":"https://github.com/wlabarron/static-search","last_synced_at":"2026-01-12T13:57:55.643Z","repository":{"id":40381443,"uuid":"369146763","full_name":"wlabarron/static-search","owner":"wlabarron","description":"Search for static websites, powered by Cloudflare Workers and Fuse.js.","archived":false,"fork":false,"pushed_at":"2023-10-25T20:25:38.000Z","size":23,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-15T07:30:52.751Z","etag":null,"topics":["cloudflare","cloudflare-workers","fusejs","jamstack","search"],"latest_commit_sha":null,"homepage":"https://awmb.uk/2021/05/search","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wlabarron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-20T09:05:35.000Z","updated_at":"2024-10-10T05:26:04.000Z","dependencies_parsed_at":"2022-09-15T16:04:12.085Z","dependency_job_id":null,"html_url":"https://github.com/wlabarron/static-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/wlabarron%2Fstatic-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlabarron%2Fstatic-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlabarron%2Fstatic-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlabarron%2Fstatic-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wlabarron","download_url":"https://codeload.github.com/wlabarron/static-search/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239988388,"owners_count":19729985,"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","cloudflare-workers","fusejs","jamstack","search"],"created_at":"2024-10-14T07:30:08.207Z","updated_at":"2026-01-12T13:57:55.628Z","avatar_url":"https://github.com/wlabarron.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Static Search\nThis is a super simple search API for static websites. It pulls data from a JSON file, created as part of the static website's build process, and stores this search index in Workers KV. You can then query the index using GET requests.\n\nThe search is configurable and done using [Fuse.js](https://fusejs.io/), and the system runs serverlessly on [Cloudflare Workers](https://workers.cloudflare.com).\n\n## Usage\nThere's probably a nice way to do this using `wrangler generate`. The following instructions are mostly notes to myself. Contributions to improve this and make it better for others are welcome, in case I never get around to it. The following assumes you're deploying the Worker on `https://yoursite/search`, which is also the URL of your search results page.\n\n1. Structure your website data. For a Jekyll site where you're only looking to search through blog posts, this might look like the `jekyll.json` file renamed and put into your site's root. Effectively, the goal is to get everything you wish to be searchable as a big JSON array somewhere on the internet.\n2. Copy `config.js.template` to `config.js`, and fill in your details.\n3. Copy `wrangler.toml.template` to `wrangler.toml`, and fill in your details. You can find out more about configuring for deployment in [Cloudflare's documentation](https://developers.cloudflare.com/workers/get-started/guide#7-configure-your-project-for-deployment). Remember to [create a KV Namespace](https://developers.cloudflare.com/workers/cli-wrangler/commands#getting-started) and put the ID into the `wrangler.toml` file, with the binding `CONTENT`.\n4. Deploy your updated static site and Worker.\n5. As part of your static site deployment process, include a request to your Worker on the path `/refresh`, and the authentication header you set in `config.js`. For example, `curl \"https://yoursite/search/refresh\" --header \"Authentication: Secure_Password\"`. That will update the Worker's search index.\n6. Build your front end. You can make search queries to your Worker at `/api?q=\u003cquery text\u003e`, for example `curl \"https://yoursite/search/api?q=installation%20instructions\"` would return the results of a search for \"installation instructions\".\n    \nIf your search results page makes use of a URL parameter named `q` for the search query, a link preload header will be added to the page. This means the API request happens (approximately) as soon as the main page starts loading, so by the time your script executes the results are probably already cached and good to go. Some front-end JavaScript to get you started:\n``` js\nfetch(\"https://yoursite/search/api?q=\" + encodeURIComponent(url.searchParams.get(\"q\")), {\n    credentials: 'include',\n    mode: 'no-cors'\n})\n    .then(function (response) {\n        return response.json();\n    })\n    .then(function (results) {\n        // output results\n    })\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlabarron%2Fstatic-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwlabarron%2Fstatic-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlabarron%2Fstatic-search/lists"}